docs: split clan-core options into sub-pages
This commit is contained in:
parent
c57cc5204c
commit
5e33a0b3b8
|
@ -46,27 +46,32 @@ nav:
|
|||
- Flake-parts: getting-started/flake-parts.md
|
||||
- Templates: templates/index.md
|
||||
- Reference:
|
||||
- ClanCore: reference/clan-core.md
|
||||
- ClanModules:
|
||||
- reference/borgbackup.md
|
||||
- reference/deltachat.md
|
||||
- reference/diskLayouts.md
|
||||
- reference/ergochat.md
|
||||
- reference/graphical.md
|
||||
- reference/localbackup.md
|
||||
- reference/localsend.md
|
||||
- reference/matrix-synapse.md
|
||||
- reference/moonlight.md
|
||||
- reference/root-password.md
|
||||
- reference/sshd.md
|
||||
- reference/sunshine.md
|
||||
- reference/syncthing.md
|
||||
- reference/thelounge.md
|
||||
- reference/vm-user.md
|
||||
- reference/waypipe.md
|
||||
- reference/xfce-vm.md
|
||||
- reference/xfce.md
|
||||
- reference/zt-tcp-relay.md
|
||||
- clan-core:
|
||||
- reference/clan-core/index.md
|
||||
- reference/clan-core/backups.md
|
||||
- reference/clan-core/facts.md
|
||||
- reference/clan-core/sops.md
|
||||
- reference/clan-core/state.md
|
||||
- clanModules:
|
||||
- reference/clanModules/borgbackup.md
|
||||
- reference/clanModules/deltachat.md
|
||||
- reference/clanModules/diskLayouts.md
|
||||
- reference/clanModules/ergochat.md
|
||||
- reference/clanModules/graphical.md
|
||||
- reference/clanModules/localbackup.md
|
||||
- reference/clanModules/localsend.md
|
||||
- reference/clanModules/matrix-synapse.md
|
||||
- reference/clanModules/moonlight.md
|
||||
- reference/clanModules/root-password.md
|
||||
- reference/clanModules/sshd.md
|
||||
- reference/clanModules/sunshine.md
|
||||
- reference/clanModules/syncthing.md
|
||||
- reference/clanModules/thelounge.md
|
||||
- reference/clanModules/vm-user.md
|
||||
- reference/clanModules/waypipe.md
|
||||
- reference/clanModules/xfce-vm.md
|
||||
- reference/clanModules/xfce.md
|
||||
- reference/clanModules/zt-tcp-relay.md
|
||||
- Contributing: contributing/contributing.md
|
||||
|
||||
docs_dir: site
|
||||
|
|
|
@ -47,6 +47,10 @@ def replace_store_path(text: str) -> Path:
|
|||
return Path(res)
|
||||
|
||||
|
||||
def render_option_header(name: str) -> str:
|
||||
return f"# {name}\n"
|
||||
|
||||
|
||||
def render_option(name: str, option: dict[str, Any]) -> str:
|
||||
read_only = option.get("readOnly")
|
||||
|
||||
|
@ -116,16 +120,38 @@ def produce_clan_core_docs() -> None:
|
|||
if not OUT:
|
||||
raise ValueError(f"Environment variables are not set correctly: $out={OUT}")
|
||||
|
||||
# A mapping of output file to content
|
||||
core_outputs: dict[str, str] = {
|
||||
"clan-core/index.md": "",
|
||||
}
|
||||
with open(CLAN_CORE) as f:
|
||||
options: dict[str, dict[str, Any]] = json.load(f)
|
||||
module_name = "clan-core"
|
||||
output = module_header(module_name)
|
||||
for option_name, info in options.items():
|
||||
output += render_option(option_name, info)
|
||||
outfile = f"{module_name}/index.md"
|
||||
|
||||
outfile = Path(OUT) / f"{module_name}.md"
|
||||
with open(outfile, "w") as of:
|
||||
of.write(output)
|
||||
# Create seperate files for nested options
|
||||
if len(option_name.split(".")) <= 2:
|
||||
# i.e. clan-core.clanDir
|
||||
output = module_header(module_name)
|
||||
output += render_option(option_name, info)
|
||||
core_outputs[outfile] += output
|
||||
|
||||
else:
|
||||
# Clan sub-options
|
||||
[_, sub] = option_name.split(".")[0:2]
|
||||
outfile = f"{module_name}/{sub}.md"
|
||||
# Get the content or write the header
|
||||
output = core_outputs.get(outfile, render_option_header(sub))
|
||||
output += render_option(option_name, info)
|
||||
# Update the content
|
||||
core_outputs[outfile] = output
|
||||
|
||||
print(core_outputs)
|
||||
for outfile, output in core_outputs.items():
|
||||
(Path(OUT) / outfile).parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(Path(OUT) / outfile, "w") as of:
|
||||
of.write(output)
|
||||
|
||||
|
||||
def produce_clan_modules_docs() -> None:
|
||||
|
@ -149,7 +175,8 @@ def produce_clan_modules_docs() -> None:
|
|||
for option_name, info in options.items():
|
||||
output += render_option(option_name, info)
|
||||
|
||||
outfile = Path(OUT) / f"{module_name}.md"
|
||||
outfile = Path(OUT) / f"clanModules/{module_name}.md"
|
||||
outfile.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(outfile, "w") as of:
|
||||
of.write(output)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user