First working version of Mermaid class diagram generator

This commit is contained in:
Bartek Kryza
2023-09-06 21:20:57 +02:00
parent 6822930a12
commit 084bb20ef7
372 changed files with 1102 additions and 821 deletions

47
util/generate_mermaid.py Normal file
View File

@@ -0,0 +1,47 @@
#!/usr/bin/python3
##
## util/validate_json.py
##
## Copyright (c) 2021-2023 Bartek Kryza <bkryza@gmail.com>
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
import sys
import subprocess
from pathlib import Path
def print_usage():
print(f'Usage: ./generate_mermaid.py file1.mmd file2.mmd ...')
files = sys.argv[1:]
if not files:
print_usage()
sys.exit(1)
ok = 0
for f in files:
try:
print(f'Generating Mermaid diagram from {f}')
f_svg = Path(f).with_suffix('.png')
subprocess.check_call(['mmdc', '-i', f, '-o', f_svg])
except subprocess.CalledProcessError:
ok = 1
print(f'ERROR: Generating Mermaid diagram from {f} failed')
sys.exit(ok)