Sphinx extension to support docstrings in Numpy format
Build a small utility that runs docstring style validation with error codes, reports results, and hooks into a documentation build to stop on configured failures.
GL08 and RT02, and the results include the fully qualified object name plus line numbers. @testGL08, that code is filtered out of the results while other codes (for example, RT02) remain. @testnumpydoc ignore=GL08,RT02 suppresses those codes, but unrelated codes (for example, SS01) are still reported. @testfail_on, and raises a build error when any code in fail_on is present. @testfailed when any fail_on code is found and passed otherwise. @test@generates
from typing import Iterable, Mapping
def validate_modules(module_paths: Iterable[str], ignore: list[str] | None = None, fail_on: list[str] | None = None) -> dict[str, list[dict]]:
"""Run docstring validation for each module path and return structured results with codes, messages, and line numbers."""
def summarize_results(results: Mapping[str, list[dict]], fail_on: list[str] | None = None) -> dict[str, object]:
"""Return aggregate counts per error code, ordered list of failing objects, and overall status string."""
def register_sphinx(app, fail_on: list[str] | None = None, warn_on: list[str] | None = None) -> None:
"""Attach validation to a Sphinx app so builds warn or fail based on validation codes."""Docstring parsing, rendering, and validation with error code reporting.
Documentation builder that hosts the validation hook.
tessl i tessl/pypi-numpydoc@1.9.0evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9