mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-05-29 21:37:42 -04:00
commit
f7deb3d699
2 changed files with 6 additions and 5 deletions
7
.github/scripts/sync-wiki.py
vendored
7
.github/scripts/sync-wiki.py
vendored
|
|
@ -5,6 +5,7 @@ from pathlib import Path
|
|||
|
||||
DOCS_DIR = Path("docs")
|
||||
WIKI_DIR = Path("wiki-temp")
|
||||
LATEST_DIR = DOCS_DIR / "(git)"
|
||||
|
||||
FRONTMATTER_RE = re.compile(r"\A---\s*\n.*?^---\s*\n", re.DOTALL | re.MULTILINE)
|
||||
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 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))
|
||||
|
||||
for subdir in sorted(DOCS_DIR.iterdir()):
|
||||
for subdir in sorted(LATEST_DIR.iterdir()):
|
||||
if subdir.is_dir():
|
||||
for src in from_dir(subdir):
|
||||
files.append((src, src.stem))
|
||||
|
|
@ -44,7 +45,7 @@ def main() -> None:
|
|||
lines: list[str] = []
|
||||
current_section = None
|
||||
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 current_section is not None:
|
||||
lines.append("")
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ jobs:
|
|||
python3 ./.github/scripts/generate-nix-options-docs.py \
|
||||
/tmp/nixos-raw.md \
|
||||
/tmp/hm-raw.md \
|
||||
docs/nix-options.md
|
||||
'docs/(git)/nix-options.md'
|
||||
|
||||
- name: Auto-commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: "docs: auto-generate Nix module options"
|
||||
file_pattern: 'docs/*-options.md'
|
||||
file_pattern: 'docs/**/nix-options.md'
|
||||
branch: ${{ github.head_ref }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue