numpydoc
numpydoc is a Sphinx extension that enables the use of NumPy-style docstrings in Sphinx-generated documentation. It processes docstrings formatted according to the NumPy documentation format, adding functionality like autodoc integration and custom directives for functions and classes. The current version is 1.10.0, with releases occurring a few times a year.
Warnings
- breaking numpydoc version 1.10.0 and later require Python 3.10+. Support for Python 3.9 and earlier has been dropped. Version 1.6.0 introduced a requirement for Python 3.8+.
- breaking numpydoc version 1.10.0 and later require Sphinx 6+. Earlier versions (e.g., 1.6.0) required Sphinx 5+, and even older versions had lower requirements (e.g., 1.2.1 required Sphinx 1.8+).
- deprecated The `numpydoc_edit_link` configuration option was deprecated in version 1.3rc1 and subsequently removed. Its functionality for inserting an edit link is now handled via HTML templates.
- gotcha numpydoc introduced support for configuration via `pyproject.toml` in version 1.6.0, with enhancements (e.g., `exclude_files` for validation) in 1.10.0. While `conf.py` remains the primary config, users transitioning or with complex build systems should be aware of `pyproject.toml` options.
- gotcha The command-line interfaces (CLIs) for numpydoc were unified in version 1.8.0. If you were using separate or older CLI commands, they might have changed.
- gotcha CSS styling for definition lists changed significantly in numpydoc versions less than 0.8 and Sphinx versions less than 2.0. This can cause rendering issues, especially with themes like `sphinx-rtd-theme`.
Install
-
pip install numpydoc
Imports
- numpydoc
# In your Sphinx conf.py file: extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.autosummary', # Automatically loaded by numpydoc 'numpydoc' ]
Quickstart
# conf.py (in your Sphinx project's docs/source directory)
import os
import sys
# If your project is a package, add its path to sys.path
# sys.path.insert(0, os.path.abspath('../../src')) # Example for a 'src' directory two levels up
project = 'My Project'
copyright = '2026, Your Name'
author = 'Your Name'
release = '0.1'
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'numpydoc'
]
templates_path = ['_templates']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']
# Numpydoc specific configuration (optional, set as needed)
numpydoc_show_class_members = False
numpydoc_class_members_toctree = False
numpydoc_xref_param_type = True
# To enable validation of docstrings during build
numpydoc_validation_checks = {"all"}