from pathlib import Path from docforge.loaders import GriffeLoader, discover_module_paths from docforge import MkDocsRenderer def test_mkdocs_emits_all_modules(tmp_path: Path) -> None: project_root = Path(__file__).resolve().parents[3] loader = GriffeLoader() discovered_paths = discover_module_paths( "docforge", project_root=project_root, ) project = loader.load_project(discovered_paths) 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(".") 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}"