Skip to content

Commit bdda056

Browse files
authored
DOC: Add section about validation via sphinx-build. (#312)
Adds a section to the documentation on validation describing how numpydoc can be configured to run docstring validation during the sphinx-build process.
1 parent ce6666a commit bdda056

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

doc/validation.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,35 @@ For an exhaustive validation of the formatting of the docstring, use the
1616
incorrect capitalization, wrong order of the sections, and many other
1717
issues.
1818

19+
Docstring Validation during Sphinx Build
20+
----------------------------------------
21+
22+
It is also possible to run docstring validation as part of the sphinx build
23+
process.
24+
This behavior is controlled by the ``numpydoc_validation_checks`` configuration
25+
parameter in ``conf.py``.
26+
For example, to verify that all of the parameters in the function signature
27+
are accounted for in the ``Parameters`` section of the docstring, add the
28+
following line to ``conf.py``::
29+
30+
numpydoc_validation_checks = {"PR01"}
31+
32+
This will cause a sphinx warning to be raised for any (non-module) docstring
33+
that has undocumented parameters in the signature.
34+
The full set of validation checks can be activated by::
35+
36+
numpydoc_validation_checks = {"all"}
37+
38+
The complete validation suite contains `many checks <validation_checks>`_
39+
including some for style, capitalization, and grammar.
40+
It is unlikely that reporting *all* validation warnings is desireable for
41+
most use-cases.
42+
Individual checks can be excluded by including them in the set with the
43+
special keyword ``"all"``::
44+
45+
# Report warnings for all validation checks except GL01, GL02, and GL05
46+
numpydoc_validation_checks = {"all", "GL01", "GL02", "GL05"}
47+
1948
.. _validation_checks:
2049

2150
Built-in Validation Checks

0 commit comments

Comments
 (0)