docs: Add UUID to docs yaml blocks (#3251)

This commit is contained in:
Travis Groth 2022-04-08 10:54:27 -04:00 committed by GitHub
parent 5e836913ae
commit cbe90fd96d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 2445 additions and 2249 deletions

View file

@ -1,7 +1,10 @@
#!/usr/bin/env python3
import os.path
import uuid
from typing import Any, IO
import yaml
from ruamel.yaml import YAML
yaml = YAML()
def main():
@ -10,9 +13,16 @@ def main():
d = os.path.normpath(d)
print(f"generating {d}/readme.md")
f = open(os.path.join(d, "settings.yaml"))
doc = yaml.full_load(f)
f.close()
settings_path = f"{d}/settings.yaml"
enterprise_settings_path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..',
'docs', 'enterprise', 'console-settings.yaml'))
rewrite_settings_yaml(settings_path)
rewrite_settings_yaml(enterprise_settings_path)
with open(settings_path) as f:
doc = yaml.load(f)
f = open(os.path.join(os.path.dirname(__file__),
"..", "docs", "reference", "readme.md"), "w")
@ -22,6 +32,25 @@ def main():
f.close()
def rewrite_settings_yaml(path):
with open(path) as f:
doc = yaml.load(f)
add_uuid(doc['settings'])
with open(path, 'w') as f:
yaml.dump(doc, f)
def add_uuid(settings):
for setting in settings:
if not 'uuid' in setting:
setting['uuid'] = str(uuid.uuid4())
if 'settings' in setting:
add_uuid(setting['settings'])
def write_setting(w, depth, setting):
if 'name' in setting:
w.write(f"{'#' * depth} {setting.get('name', '')}\n")