Merge pull request #979 from xtheeq/main

docs: add versioned docs
This commit is contained in:
DreamMaoMao 2026-05-26 14:33:57 +08:00 committed by GitHub
commit f7deb3d699
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 5 deletions

View file

@ -5,6 +5,7 @@ from pathlib import Path
DOCS_DIR = Path("docs") DOCS_DIR = Path("docs")
WIKI_DIR = Path("wiki-temp") WIKI_DIR = Path("wiki-temp")
LATEST_DIR = DOCS_DIR / "(git)"
FRONTMATTER_RE = re.compile(r"\A---\s*\n.*?^---\s*\n", re.DOTALL | re.MULTILINE) FRONTMATTER_RE = re.compile(r"\A---\s*\n.*?^---\s*\n", re.DOTALL | re.MULTILINE)
DOCS_LINK_RE = re.compile(r"\[([^\]]+)\]\(/docs/(?:[^/)]+/)*([^/)#]+)(#[^)]+)?\)") DOCS_LINK_RE = re.compile(r"\[([^\]]+)\]\(/docs/(?:[^/)]+/)*([^/)#]+)(#[^)]+)?\)")
@ -20,10 +21,10 @@ def collect_all_files() -> list[tuple[Path, str]]:
return [directory / f"{p}.md" for p in data.get("pages", []) if (directory / f"{p}.md").exists()] return [directory / f"{p}.md" for p in data.get("pages", []) if (directory / f"{p}.md").exists()]
return sorted(directory.glob("*.md")) return sorted(directory.glob("*.md"))
for src in from_dir(DOCS_DIR): for src in from_dir(LATEST_DIR):
files.append((src, "Home" if src.stem == "index" else src.stem)) files.append((src, "Home" if src.stem == "index" else src.stem))
for subdir in sorted(DOCS_DIR.iterdir()): for subdir in sorted(LATEST_DIR.iterdir()):
if subdir.is_dir(): if subdir.is_dir():
for src in from_dir(subdir): for src in from_dir(subdir):
files.append((src, src.stem)) files.append((src, src.stem))
@ -44,7 +45,7 @@ def main() -> None:
lines: list[str] = [] lines: list[str] = []
current_section = None current_section = None
for src, dest_name in files: for src, dest_name in files:
section = "General" if src.parent == DOCS_DIR else src.parent.name.replace("-", " ").title() section = "General" if src.parent == LATEST_DIR else src.parent.name.replace("-", " ").title()
if section != current_section: if section != current_section:
if current_section is not None: if current_section is not None:
lines.append("") lines.append("")

View file

@ -53,11 +53,11 @@ jobs:
python3 ./.github/scripts/generate-nix-options-docs.py \ python3 ./.github/scripts/generate-nix-options-docs.py \
/tmp/nixos-raw.md \ /tmp/nixos-raw.md \
/tmp/hm-raw.md \ /tmp/hm-raw.md \
docs/nix-options.md 'docs/(git)/nix-options.md'
- name: Auto-commit changes - name: Auto-commit changes
uses: stefanzweifel/git-auto-commit-action@v5 uses: stefanzweifel/git-auto-commit-action@v5
with: with:
commit_message: "docs: auto-generate Nix module options" commit_message: "docs: auto-generate Nix module options"
file_pattern: 'docs/*-options.md' file_pattern: 'docs/**/nix-options.md'
branch: ${{ github.head_ref }} branch: ${{ github.head_ref }}