Updated docs generation scripts

This commit is contained in:
Bartek Kryza
2023-09-10 00:03:47 +02:00
parent 2cc70bcd7e
commit 9a6def801c
6 changed files with 34 additions and 14 deletions

View File

@@ -38,8 +38,11 @@ ok = 0
for f in files:
try:
print(f'Generating Mermaid diagram from {f}')
f_svg = Path(f).with_suffix('.svg')
subprocess.check_call(['mmdc', '-i', f, '-o', f_svg])
f_svg = Path(f).with_suffix('.svg').name
target = Path(f).parent.absolute()
target = target.joinpath('mermaid')
target = target.joinpath(f_svg)
subprocess.check_call(['mmdc', '-i', f, '-o', target])
except subprocess.CalledProcessError:
ok = 1
print(f'ERROR: Generating Mermaid diagram from {f} failed')

View File

@@ -71,20 +71,21 @@ with open(r'tests/test_cases.yaml') as f:
config_dict = yaml.full_load(config)
tc.write("## Generated PlantUML diagrams\n")
for diagram_name, _ in config_dict['diagrams'].items():
copyfile(f'debug/tests/diagrams/puml/{diagram_name}.svg',
copyfile(f'debug/tests/diagrams/plantuml/{diagram_name}.svg',
f'docs/test_cases/{diagram_name}.svg')
tc.write(f'![{diagram_name}](./{diagram_name}.svg "{test_case["title"]}")\n')
tc.write("## Generated Mermaid diagrams\n")
for diagram_name, _ in config_dict['diagrams'].items():
copyfile(f'debug/tests/diagrams/mermaid/{diagram_name}.svg',
f'docs/test_cases/{diagram_name}_mmd.svg')
tc.write(f'![{diagram_name}](./{diagram_name}_mmd.svg "{test_case["title"]}")\n')
f'docs/test_cases/{diagram_name}_mermaid.svg')
tc.write(f'![{diagram_name}](./{diagram_name}_mermaid.svg "{test_case["title"]}")\n')
tc.write("## Generated JSON models\n")
for diagram_name, _ in config_dict['diagrams'].items():
if os.path.exists(f'debug/tests/puml/{diagram_name}.json'):
with open(f'debug/tests/puml/{diagram_name}.json') as f:
jd = f'debug/tests/diagrams/{diagram_name}.json'
if os.path.exists(jd):
with open(jd) as f:
contents = f.read()
tc.write("```json\n")
tc.write(contents)