nested_pages: Katalogtiefe 1 durchgesetzt, layout:-dir validiert, move raeumt geleerte Verzeichnisse - die drei #57-Seiten hochgezogen (schliesst #57)
CI / verify (push) Successful in 1m0s
Release / release (push) Successful in 37s

Files changed:
- CHANGES.md
- VERSION
- kb/CONTRACT.md
- kb/entities/projects/kfchou/wiki-skills.md
- kb/entities/projects/llm-wiki-skills.md
- kb/entities/projects/vanillaflava/wiki-skills-vanillaflava.md
- kb/entities/projects/wiki-skills-vanillaflava.md
- kb/entities/projects/wiki-skills.md
- kb/entities/projects/yugasun/llm-wiki-skills.md
- kb/log.md
- tools/CONTRACT.md
- tools/chemenu/commands/index_build.py
- tools/chemenu/commands/page_ops.py
- tools/chemenu/kb_scan.py
- tools/chemenu/lint_core.py
- tools/chemenu/tests/test_index_build.py
- tools/chemenu/tests/test_kb_scan.py
- tools/chemenu/tests/test_lint.py
- tools/chemenu/tests/test_page_ops.py
- tools/chemenu/tests/test_type_resolver.py
- tools/chemenu/type_resolver.py
This commit is contained in:
torben committed 2026-09-04 23:19:30 +02:00
1 parent 9e414319b8
commit 251e597c63
18 files changed
+331 -10

No files matched your search

+26
View File
@@ -120,6 +120,32 @@ def count_wikilinks(body: str) -> Counter[str]:
return Counter(m.group(1).strip() for m in WIKILINK_RE.finditer(strip_code_spans(body)))
def find_nested_pages(kb_dir: Path, pages: dict[str, Page]) -> list[tuple[str, Page, int]]:
"""(title, page, depth) for every page sitting more than one directory
below its collection.
`kb/<collection>/<page>.md` and `kb/<collection>/<area>/<page>.md` are the
only two depths `kb/CONTRACT.md` § Collections describes. A third level is
not merely unconventional - it is invisible to the catalog:
`index_build.group_pages` reads exactly `parts[0]`/`parts[1]` and folds
anything past them into the area's table silently (Gitea #57), so a page
down here renders as if it sat directly in the area, under no name of its
own. `depth` is how many directories separate the page from its
collection root (1 = directly in an area, the deepest that is not this
finding).
"""
found = []
for title, page in sorted(pages.items()):
try:
parts = page.path.relative_to(kb_dir).parts
except ValueError:
continue
depth = len(parts) - 2 # collection + filename are always present
if depth > 1:
found.append((title, page, depth))
return found
def build_link_graph(pages: dict[str, Page]) -> dict[str, set[str]]:
"""Map each page title to the set of titles it links to."""
return {title: extract_wikilinks(page.body) for title, page in pages.items()}