File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717src = root
1818for 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 )
You can’t perform that action at this time.
0 commit comments