ENH: Migrate numpydoc validation to sphinx#64595
Open
tuhinsharma121 wants to merge 6 commits intopandas-dev:mainfrom
Open
ENH: Migrate numpydoc validation to sphinx#64595tuhinsharma121 wants to merge 6 commits intopandas-dev:mainfrom
tuhinsharma121 wants to merge 6 commits intopandas-dev:mainfrom
Conversation
98f13e6 to
5e7abea
Compare
a60e90b to
87bb56a
Compare
87bb56a to
1af9932
Compare
mroeschke
requested changes
Mar 16, 2026
Member
mroeschke
left a comment
There was a problem hiding this comment.
Thanks! Generally looking good
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
50c9384 to
a60b01b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/validate_docstrings.py(480 lines) and its test suitescripts/tests/test_validate_docstrings.pyby integrating all pandas-specific docstring checks directly into the Sphinx build via a monkey-patch ofnumpydoc.validateindoc/source/conf.py.numpydoc_validation_checks = {"all"}with an explicitnumpydoc_validation_excludeset of 171 fully-qualified object names (replacing the previous 25 regex wildcards), so every public API object is validated during the documentation build.ci/code_checks.sh docstringsCI step and its corresponding GitHub Actions workflow entry, since validation is now handled entirely by Sphinx.Motivation
(following up on #64565 (comment))
Previously, pandas maintained two independent validation paths: numpydoc's built-in Sphinx checks and a custom standalone script (
scripts/validate_docstrings.py) that enforced four pandas-specific rules (GL04, PD01, SA05, EX04). This had several downsides:By monkey-patching
numpydoc.validate.validateinconf.py, all checks (standard numpydoc + pandas-specific) now run in a single pass during the Sphinx build. Contributors only need one command to validate a docstring.Changes
doc/source/conf.pyGL04,PD01,SA05,EX04) intonumpydoc.validate.ERROR_MSGSand wraps thevalidatefunction.numpydoc_validation_checks = {"all"}to enable comprehensive validation.numpydoc_validation_excludewith 171 explicit fully-qualified entries replacing the previous regex wildcards for objects that legitimately cannot have numpydoc-compliant docstrings (e.g., Jinja2 template attributes) or are missed out (e.g. offset.base/.rollback/.rollforwardmethods,ExtensionDtypestubs).scripts/validate_docstrings.py(deleted)scripts/tests/test_validate_docstrings.py(deleted)ci/code_checks.sh### DOCSTRINGS ###section that invokedscripts/validate_docstrings.py.docstringsfrom the usage instructions and argument validation.BASE_DIRvariable..github/workflows/code-checks.ymlRun docstring validationstep (ci/code_checks.sh docstrings).doc/source/development/contributing_documentation.rstscripts/validate_docstrings.pywith the single recommended command for validating a docstring:python doc/make.py --warnings-are-errors --no-browser --single pandas.DataFrame.meandoc/source/development/contributing_codebase.rstci/code_checks.shto reflect that standard numpydoc validation is now enforced during the Sphinx build.Test plan
python doc/make.py --warnings-are-errors --no-browser --single pandas.DataFrame.meanand verify it completes without errors.SA05violation (e.g., addpandas.Series.renameto a See Also section) and verify the single-page build catches it../ci/code_checks.shand verify all remaining checks (code, doctests, single-docs, notebooks) pass without the removeddocstringsstep.cd doc && python make.py --num-jobs 1 html) and verify no regressions in validation warnings.