talira

sphinx-autodoc-typehints

Render Python type hints in Sphinx autodoc documentation

open sourceMITfree

sphinx-autodoc-typehints is a Sphinx extension that reads the type hints of the code autodoc documents and writes them into the parameter and return fields, so each type is stated once, in the code. It links every part of a type to its documentation, resolves names imported only for type checkers (inside if TYPE_CHECKING:) or declared in .pyi stubs, documents @overload variants and default values, and types Google and NumPy style docstrings for napoleon or numpydoc. It's maintained by the tox-dev organization.

Problems it solves

  • show Python type hints in Sphinx API docs
  • stop repeating types in docstrings and annotations
  • document typing overloads with Sphinx autodoc

Features

  • type hints written into parameter and return fields
  • links each part of a type to its docs
  • resolves TYPE_CHECKING imports and .pyi stubs
  • documents overloads and defaults
  • works with napoleon and numpydoc

Alternatives

The same job

These do what sphinx-autodoc-typehints does.

  1. Sphinx Create intelligent and beautiful documentation with ease
  2. numpydoc Sphinx extension for NumPy-style docstrings
  3. sphinx-autobuild Rebuild Sphinx docs on changes, with hot reloading in the browser
  4. PyData Sphinx Theme Clean, three-column, Bootstrap-based theme for Sphinx docs
  5. Read the Docs Sphinx Theme The Read the Docs theme for Sphinx documentation
  6. MyST-Parser Write Sphinx and Docutils documentation in MyST Markdown

Compare sphinx-autodoc-typehints with the top 3