Skip to content

Commit

Permalink
(Aegis) Generate mermaid flowcharts
Browse files Browse the repository at this point in the history
  • Loading branch information
ahyangyi committed Nov 12, 2023
1 parent 48ec6ff commit 9db52c7
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ group :jekyll_plugins do
end
gem "just-the-docs", "0.7.0"
gem 'jekyll-multiple-languages-plugin'
gem "jekyll-mermaid"
2 changes: 2 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ GEM
webrick (~> 1.7)
jekyll-include-cache (0.2.1)
jekyll (>= 3.7, < 5.0)
jekyll-mermaid (1.0.0)
jekyll-multiple-languages-plugin (1.8.0)
jekyll (>= 2.0, < 5.0)
jekyll-sass-converter (3.0.0)
Expand Down Expand Up @@ -77,6 +78,7 @@ PLATFORMS

DEPENDENCIES
jekyll
jekyll-mermaid
jekyll-multiple-languages-plugin
just-the-docs (= 0.7.0)

Expand Down
3 changes: 3 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ github_username: ahyangyi
theme: just-the-docs
plugins:
- jekyll-multiple-languages-plugin
- jekyll-mermaid
mermaid:
src: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js'
languages: ["en-GB", "zh-CN"]
exclude_from_localizations: ["js", "imgs", "css"]
markdown: kramdown
Expand Down
20 changes: 20 additions & 0 deletions industry/docgen/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,29 @@ def gen_economy_doc(all_economies, string_manager):
search_exclude: true"""

with open(os.path.join(prefix, f"{meta_economy.name}_{variation_desc}.md"), "w") as f:
# Flowchart
print(
f"""{header}
---
# Flowchart
{{% mermaid %}}
flowchart LR;""",
file=f,
)
for industry in economy.industries:
print(f"INDUSTRY_{industry.translation_name}[{industry.name(string_manager)}];", file=f)
for cargo in economy.cargos:
print(f"CARGO_{cargo.label.decode()}(({cargo.name(string_manager)}));", file=f)
for industry, flow in economy.graph.items():
for cargo in flow.accepts:
print(f"CARGO_{cargo.label.decode()} --> INDUSTRY_{industry.translation_name};", file=f)
for cargo in flow.produces:
print(f"INDUSTRY_{industry.translation_name} --> CARGO_{cargo.label.decode()};", file=f)

# Industries
print(
f"""{{% endmermaid %}}
# Industries
| Industry | Accepts | Produces |
Expand Down

0 comments on commit 9db52c7

Please sign in to comment.