missing internal modules test case
This commit is contained in:
36
tests/renderers/test_mkdocs_module_coverage.py
Normal file
36
tests/renderers/test_mkdocs_module_coverage.py
Normal 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}"
|
||||||
Reference in New Issue
Block a user