Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/codealmanac/services/wiki/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def is_reserved_page_path(almanac_path: Path, path: Path) -> bool:
relative = path.relative_to(almanac_path)
except ValueError:
return True
return any(part in RESERVED_WIKI_SOURCE_DIRS for part in relative.parts[:-1])
directories = relative.parts[:-1]
return bool(directories) and directories[0] in RESERVED_WIKI_SOURCE_DIRS


def page_id_for_path(almanac_path: Path, page_path: Path) -> str:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_wiki_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,23 @@ def test_page_iteration_excludes_repository_manuals(tmp_path):
assert tuple(iter_page_paths(almanac_path)) == (page,)


def test_page_iteration_keeps_nested_dirs_named_after_reserved_roots(tmp_path):
almanac_path = tmp_path / "almanac"
reserved_manual = almanac_path / "manual"
reserved_manual.mkdir(parents=True)
(reserved_manual / "how-to-write.md").write_text("# Manual\n", encoding="utf-8")

nested_jobs = almanac_path / "architecture/jobs/queue.md"
nested_jobs.parent.mkdir(parents=True)
nested_jobs.write_text("# Queue\n", encoding="utf-8")

nested_manual = almanac_path / "guides/manual/setup.md"
nested_manual.parent.mkdir(parents=True)
nested_manual.write_text("# Setup\n", encoding="utf-8")

assert tuple(iter_page_paths(almanac_path)) == (nested_jobs, nested_manual)


def test_frontmatter_uses_pydantic_validated_shape():
parsed = parse_frontmatter(
"""---
Expand Down