Skip to content

Commit

Permalink
Add "Host Templates" section to docs
Browse files Browse the repository at this point in the history
These will live in `hosts/_templates`
  • Loading branch information
barrucadu committed Dec 10, 2024
1 parent 01050d3 commit 3dcb95f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ book
# generated by the build script
src/README.md
src/hosts.md
src/host-templates.md
src/modules.md
src/options.md
src/packages.md
Expand Down
1 change: 1 addition & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Reference

- [Hosts](./hosts.md)
- [Host Templates](./host-templates.md)
- [Modules](./modules.md)
- [Options](./options.md)

Expand Down
34 changes: 33 additions & 1 deletion scripts/documentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import os
print("# Hosts")
print("")
hosts = sorted([name for name in os.listdir("hosts") if name not in [".", ".."]])
hosts = sorted([name for name in os.listdir("hosts")])
for host in hosts:
source_file = f"hosts/{host}/configuration.nix"
if not os.path.isfile(source_file):
continue
print(f"## {host}")
has_doc = False
Expand All @@ -32,6 +35,35 @@ for host in hosts:
print("")
EOF

python3 - <<'EOF' > docs/src/host-templates.md
import os
print("# Host Templates")
print("")
templates = sorted([name for name in os.listdir("hosts/_templates")])
for template in templates:
source_file = f"hosts/_templates/{template}"
if not os.path.isfile(source_file):
continue
print(f"## {template.replace('.nix','')}")
has_doc = False
with open(source_file, "r") as f:
for line in f:
if line.startswith("#"):
has_doc = True
print(line[1:].strip())
else:
break
if not has_doc:
print("This template has no description.")
print(f"\n**Declared in:** [{source_file}](https://github.com/barrucadu/nixfiles/blob/master/{source_file})")
print("")
EOF

python3 - <<'EOF' > docs/src/modules.md
import json
import os
Expand Down

0 comments on commit 3dcb95f

Please sign in to comment.