Skip to content

Commit 8740f09

Browse files
committed
Dont try to gen. docs for certain paths
Also, more robust parsing of module to find (or not) docstring
1 parent 54a64e4 commit 8740f09

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

docs/gen_ref_pages.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,27 @@
1717
src = root
1818
for path in sorted(src.rglob("*.py")):
1919

20-
# Skip files that don't have docstrings (avoid build abortion)
20+
# Skip "venv" and other similarly named directories
21+
if path.name.startswith("venv") or path.name.startswith(".venv") or path.name.startswith(".") or "site-packages" in path.parts:
22+
continue
23+
# Skip and print "cause"
24+
cause = None
25+
try:
26+
txt = path.read_text()
27+
except UnicodeDecodeError:
28+
cause = f"Warning: Skipping (due to read error) {path.relative_to(root)}"
29+
# Skip files that don't have docstrings (to avoid build abortion)
2130
# More elaborate solution: https://github.com/mkdocstrings/mkdocstrings/discussions/412
22-
if (txt := path.read_text()) and txt.splitlines()[0][0] not in ["'", '"']:
31+
if txt and (lines := txt.splitlines()):
32+
for line in lines:
33+
line = line.strip()
34+
if not line or line.startswith("#"):
35+
continue
36+
if not line.startswith(('"', "'")):
37+
print()
38+
cause = f"Warning: Skipping (due to missing docstring) {path.relative_to(root)}"
39+
break
40+
if cause:
2341
continue
2442

2543
parts = tuple(path.relative_to(src).with_suffix("").parts)

0 commit comments

Comments
 (0)