missing internal modules test case

This commit is contained in:
2026-01-20 21:52:44 +05:30
parent 5073f9d73f
commit 2e5d330fca

View File

@@ -0,0 +1,36 @@
from pathlib import Path
from docforge.loader import GriffeLoader
from docforge.renderers.mkdocs import MkDocsRenderer
def test_mkdocs_emits_all_modules(tmp_path: Path) -> None:
loader = GriffeLoader()
project = loader.load_project(["docforge"])
renderer = MkDocsRenderer()
renderer.generate_sources(project, tmp_path)
emitted = {
p.relative_to(tmp_path).as_posix()
for p in tmp_path.rglob("*.md")
}
module_paths = [m.path for m in project.get_all_modules()]
expected = set()
for path in module_paths:
parts = path.split(".")
# treat package as index.md if any other module is nested under it
is_package = any(
other != path and other.startswith(path + ".")
for other in module_paths
)
if is_package:
expected.add("/".join(parts) + "/index.md")
else:
expected.add("/".join(parts) + ".md")
missing = expected - emitted
assert not missing, f"Missing markdown files for modules: {missing}"