docs: add automated compose documentation generation pipeline

This commit is contained in:
beatz174-bit
2026-05-13 07:45:57 +10:00
parent 5589594d2c
commit c0360a14b9
15 changed files with 256 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import sys,yaml,subprocess,shutil
inp,dotf,svgf=sys.argv[1],sys.argv[2],sys.argv[3]
with open(inp) as f:c=yaml.safe_load(f) or {}
svcs=c.get('services') or {}
lines=["digraph Compose {"," rankdir=LR;"," node [fontname=Helvetica];"]
for s in svcs: lines.append(f' "svc:{s}" [label="{s}", shape=box, style=filled, fillcolor="#dfefff"];')
for n in (c.get('networks') or {}).keys(): lines.append(f' "net:{n}" [label="{n}", shape=ellipse, style=filled, fillcolor="#f4f4f4"];')
for s,sv in svcs.items():
ns=sv.get('networks') or []
if isinstance(ns,dict): ns=ns.keys()
for n in ns: lines.append(f' "svc:{s}" -> "net:{n}";')
lines.append("}")
open(dotf,'w').write('\n'.join(lines)+'\n')
if shutil.which('dot'):
subprocess.run(['dot','-Tsvg',dotf,'-o',svgf],check=True)
else:
open(svgf,'w').write('<svg xmlns="http://www.w3.org/2000/svg" width="640" height="80"><text x="10" y="40">Graphviz dot not found in environment.</text></svg>\n')