epythet.validation.detectors¶
Named doctree detectors, referenced from ledger rules by detector.function.
Each detector takes a ParsedDocstring and
returns a list of evidence strings, one per hit (an empty list means the rule
does not fire). They read the docutils doctree rather than rendered HTML so
that the rules keep working under any Sphinx theme, and under a MkDocs
backend, exactly as decided in D8.
The detectors are the measured prototype from the validation research
(detect2.py and refine.py), ported one to one; the refinements that
took false positives from 2/14 to 1/14 on the control set are marked inline.
Module Attributes
Registry filled by |
|
Section names napoleon recognises (Google style), lower-cased. |
|
Common misspellings / near-misses of section names that napoleon ignores. |
Functions
A block quote and an |
|
|
A simple-table border in the source with no |
|
Register a detector under |
|
A directive is written in the source but produced no content node (DR018). |
|
A Markdown fence collapsed into an inline literal (DR006). |
|
Two adjacent sibling bullet lists: the marker character changed mid-list (DR022). |
|
A definition-list term that is a misspelt section name (DR013). |
|
A top-level definition list of single-word terms: probably a parameter list (DR017). |
|
Unbalanced inline markup: every |
|
A definition-list term of three or more words: prose eaten by indentation (DR014). |
|
A Google section ( |
|
Every message docutils reported while parsing the docstring (DR032). |
|
Single backticks parsed as a title reference, i.e. italics not code (DR011). |
- epythet.validation.detectors.DETECTORS: dict[str, Detector] = {'blockquote_with_unexpected_indent': <function blockquote_with_unexpected_indent>, 'collapsed_table': <function collapsed_table>, 'directive_content_lost': <function directive_content_lost>, 'markdown_fence_literal': <function markdown_fence_literal>, 'mixed_bullet_markers': <function mixed_bullet_markers>, 'near_miss_section_term': <function near_miss_section_term>, 'param_definition_list': <function param_definition_list>, 'problematic_nodes': <function problematic_nodes>, 'prose_definition_term': <function prose_definition_term>, 'section_as_definition_list': <function section_as_definition_list>, 'system_messages': <function system_messages>, 'title_references': <function title_references>}¶
Registry filled by
detector(); the ledger loader validates against it.
- epythet.validation.detectors.NAPOLEON_SECTIONS = frozenset({'args', 'arguments', 'attention', 'attributes', 'caution', 'danger', 'error', 'example', 'examples', 'hint', 'important', 'keyword args', 'keyword arguments', 'methods', 'note', 'notes', 'other parameters', 'parameters', 'raise', 'raises', 'receive', 'receives', 'references', 'return', 'returns', 'see also', 'tip', 'todo', 'warning', 'warnings', 'warns', 'yield', 'yields'})¶
Section names napoleon recognises (Google style), lower-cased.
- epythet.validation.detectors.NEAR_SECTIONS = frozenset({'arg', 'argument', 'attribute', 'exception', 'exceptions', 'exemple', 'exemples', 'kwarg', 'kwargs', 'param', 'parameter', 'params', 'rasies', 'retruns', 'returnss', 'yeilds'})¶
Common misspellings / near-misses of section names that napoleon ignores.
- epythet.validation.detectors.blockquote_with_unexpected_indent(parsed)[source]¶
A block quote and an
Unexpected indentationmessage: stray indent (DR016).The message gate is what makes this reliable; a block quote alone is how a legitimate quotation is written (research §3.3).
- epythet.validation.detectors.collapsed_table(parsed)[source]¶
A simple-table border in the source with no
tablenode in the tree (DR019).Refinement from the research: the border line must contain two or more whitespace-separated runs of
=, otherwise a section underline matches.
- epythet.validation.detectors.detector(name)[source]¶
Register a detector under
name(the name used in rule YAML).- Return type:
Callable[[Callable[[ParsedDocstring],list[str]]],Callable[[ParsedDocstring],list[str]]]
- epythet.validation.detectors.directive_content_lost(parsed)[source]¶
A directive is written in the source but produced no content node (DR018).
With stub directives registered, an unknown directive name (
.. codeblock::) or a body that docutils rejected leaves only a system message behind; the content the author wrote is gone from the page.
- epythet.validation.detectors.markdown_fence_literal(parsed)[source]¶
A Markdown fence collapsed into an inline literal (DR006).
Refinement from the research: a triple-backtick fence parses as an inline
literalwhose text starts or ends with a backtick, because two of the fence characters are consumed as the literal’s delimiters. Testing for three backticks in the paragraph text does not work.
- epythet.validation.detectors.mixed_bullet_markers(parsed)[source]¶
Two adjacent sibling bullet lists: the marker character changed mid-list (DR022).
- epythet.validation.detectors.near_miss_section_term(parsed)[source]¶
A definition-list term that is a misspelt section name (DR013).
- epythet.validation.detectors.param_definition_list(parsed)[source]¶
A top-level definition list of single-word terms: probably a parameter list (DR017).
- epythet.validation.detectors.problematic_nodes(parsed)[source]¶
Unbalanced inline markup: every
problematicnode in the tree (DR010).
- epythet.validation.detectors.prose_definition_term(parsed)[source]¶
A definition-list term of three or more words: prose eaten by indentation (DR014).
- epythet.validation.detectors.section_as_definition_list(parsed)[source]¶
A Google section (
Args:) became a definition-list term: napoleon is off (DR012).