Skip to content

Commit d0c37c4

Browse files
committed
Use griffe to filter out files that don't have docstrings
1 parent b18339a commit d0c37c4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/gen_ref_pages.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from pathlib import Path
44

55
import mkdocs_gen_files
6+
from griffe.collections import ModulesCollection
7+
from griffe.loader import GriffeLoader
68

79
TOP_LEVEL_NAME = "pytorch_adapt"
810
FOLDER = "code"
@@ -13,12 +15,17 @@ def remove_pytorch_adapt(x):
1315

1416

1517
def main():
18+
collection = ModulesCollection()
19+
loader = GriffeLoader(modules_collection=collection)
20+
loader.load_module(Path("src", TOP_LEVEL_NAME))
1621
nav = mkdocs_gen_files.Nav()
1722

1823
for path in sorted(Path("src").rglob("*.py")):
1924
module_path = path.relative_to("src").with_suffix("")
2025
parts = list(module_path.parts)
21-
if parts[-1] in ["__init__", "__main__"]:
26+
if (parts[-1] in ["__init__", "__main__"]) or (
27+
not collection[module_path.parts].has_docstrings
28+
):
2229
continue
2330

2431
doc_path = path.relative_to("src").with_suffix(".md")

0 commit comments

Comments
 (0)