epythet.validation.docstrings¶
Docstring extraction from Python source, without importing anything.
Every level below the build reads docstrings straight from the ast, so the
package under validation never has to be importable (and never runs). What
autodoc would see is approximated with inspect.cleandoc(), which is
what Sphinx’s prepare_docstring does modulo tab expansion.
Each Docstring carries both the processed text (what Python hands
to Sphinx) and the literal’s source segment (what the author typed), because
one seed rule (DR020, backslashes eaten by a non-raw string) is only visible
in the latter.
Functions
|
Count public modules, classes and functions, and those without a docstring. |
|
Whether |
|
Yield every docstring in a package directory tree. |
|
Yield the module, class and function docstrings of one file, in source order. |
|
Every |
Classes
|
How many public objects were seen and how many lack a docstring. |
|
One docstring and where it came from. |
- class epythet.validation.docstrings.Coverage(checked=0, undocumented=0)[source]¶
Bases:
objectHow many public objects were seen and how many lack a docstring.
- class epythet.validation.docstrings.Docstring(file, line, def_line, qualname, kind, text, source, is_raw)[source]¶
Bases:
objectOne docstring and where it came from.
- epythet.validation.docstrings.count_public_objects(package_dir, *, ignore=())[source]¶
Count public modules, classes and functions, and those without a docstring.
“Public” means no leading underscore anywhere in the dotted name below the package. Nested functions are counted like any other def.
- Return type:
- epythet.validation.docstrings.is_ignored(path, ignore)[source]¶
Whether
pathmatches the--ignorelist: any token is a substring of its POSIX form.The one predicate every level uses, so a file the parse level skips is also absent from the lint, coverage and repair results.
- Return type:
>>> is_ignored("/p/pkg/tests/test_x.py", ["tests/"]), is_ignored("/p/pkg/x.py", ["tests/"]) (True, False)
- epythet.validation.docstrings.iter_docstrings(package_dir, *, ignore=(), on_skip=None)[source]¶
Yield every docstring in a package directory tree.
- epythet.validation.docstrings.iter_file_docstrings(path, *, root=None, on_skip=None)[source]¶
Yield the module, class and function docstrings of one file, in source order.
A file that does not parse or decode is skipped;
on_skip(path, reason)is called so the caller can report it (a syntax error is the linter’s business, but silence would hide a docstring from the ledger).