From 9ce89bbd3d5c8d97e6c6d0869b25981c77c4b828 Mon Sep 17 00:00:00 2001 From: Jared Dillard Date: Mon, 24 Aug 2026 23:33:46 -0700 Subject: [PATCH] Doc: explain Napoleon configuration for import aliases --- doc/usage/extensions/napoleon.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/usage/extensions/napoleon.rst b/doc/usage/extensions/napoleon.rst index 469e3fddc89..f9d894e052b 100644 --- a/doc/usage/extensions/napoleon.rst +++ b/doc/usage/extensions/napoleon.rst @@ -607,6 +607,20 @@ sure that "sphinx.ext.napoleon" is enabled in ``conf.py``: :param arg2: Description of `arg2` :type arg2: :term:`dict-like ` + Import aliases used in type definitions can be translated to names present + in intersphinx inventories. For example, to translate ``np.ndarray`` to + ``numpy.ndarray``: + + .. code-block:: python + + napoleon_preprocess_types = True + napoleon_type_aliases = { + "np.ndarray": "numpy.ndarray", + } + + Napoleon cannot infer module imports from type names written in docstrings, + so aliases must be configured explicitly. + .. versionadded:: 3.2 .. confval:: napoleon_attr_annotations