docs: split clan-core options into sub-pages
This commit is contained in:
@@ -46,27 +46,32 @@ nav:
|
|||||||
- Flake-parts: getting-started/flake-parts.md
|
- Flake-parts: getting-started/flake-parts.md
|
||||||
- Templates: templates/index.md
|
- Templates: templates/index.md
|
||||||
- Reference:
|
- Reference:
|
||||||
- ClanCore: reference/clan-core.md
|
- clan-core:
|
||||||
- ClanModules:
|
- reference/clan-core/index.md
|
||||||
- reference/borgbackup.md
|
- reference/clan-core/backups.md
|
||||||
- reference/deltachat.md
|
- reference/clan-core/facts.md
|
||||||
- reference/diskLayouts.md
|
- reference/clan-core/sops.md
|
||||||
- reference/ergochat.md
|
- reference/clan-core/state.md
|
||||||
- reference/graphical.md
|
- clanModules:
|
||||||
- reference/localbackup.md
|
- reference/clanModules/borgbackup.md
|
||||||
- reference/localsend.md
|
- reference/clanModules/deltachat.md
|
||||||
- reference/matrix-synapse.md
|
- reference/clanModules/diskLayouts.md
|
||||||
- reference/moonlight.md
|
- reference/clanModules/ergochat.md
|
||||||
- reference/root-password.md
|
- reference/clanModules/graphical.md
|
||||||
- reference/sshd.md
|
- reference/clanModules/localbackup.md
|
||||||
- reference/sunshine.md
|
- reference/clanModules/localsend.md
|
||||||
- reference/syncthing.md
|
- reference/clanModules/matrix-synapse.md
|
||||||
- reference/thelounge.md
|
- reference/clanModules/moonlight.md
|
||||||
- reference/vm-user.md
|
- reference/clanModules/root-password.md
|
||||||
- reference/waypipe.md
|
- reference/clanModules/sshd.md
|
||||||
- reference/xfce-vm.md
|
- reference/clanModules/sunshine.md
|
||||||
- reference/xfce.md
|
- reference/clanModules/syncthing.md
|
||||||
- reference/zt-tcp-relay.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
|
- Contributing: contributing/contributing.md
|
||||||
|
|
||||||
docs_dir: site
|
docs_dir: site
|
||||||
|
|||||||
@@ -47,6 +47,10 @@ def replace_store_path(text: str) -> Path:
|
|||||||
return Path(res)
|
return Path(res)
|
||||||
|
|
||||||
|
|
||||||
|
def render_option_header(name: str) -> str:
|
||||||
|
return f"# {name}\n"
|
||||||
|
|
||||||
|
|
||||||
def render_option(name: str, option: dict[str, Any]) -> str:
|
def render_option(name: str, option: dict[str, Any]) -> str:
|
||||||
read_only = option.get("readOnly")
|
read_only = option.get("readOnly")
|
||||||
|
|
||||||
@@ -116,15 +120,37 @@ def produce_clan_core_docs() -> None:
|
|||||||
if not OUT:
|
if not OUT:
|
||||||
raise ValueError(f"Environment variables are not set correctly: $out={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:
|
with open(CLAN_CORE) as f:
|
||||||
options: dict[str, dict[str, Any]] = json.load(f)
|
options: dict[str, dict[str, Any]] = json.load(f)
|
||||||
module_name = "clan-core"
|
module_name = "clan-core"
|
||||||
output = module_header(module_name)
|
|
||||||
for option_name, info in options.items():
|
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"
|
# Create seperate files for nested options
|
||||||
with open(outfile, "w") as of:
|
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)
|
of.write(output)
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +175,8 @@ def produce_clan_modules_docs() -> None:
|
|||||||
for option_name, info in options.items():
|
for option_name, info in options.items():
|
||||||
output += render_option(option_name, info)
|
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:
|
with open(outfile, "w") as of:
|
||||||
of.write(output)
|
of.write(output)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user