Skip to content

Unexpected header rendered for custom Napoleon section alias #12877

@fabcor-maxiv

Description

@fabcor-maxiv

Describe the bug

For a custom Napoleon section alias we would expect the original header label to be rendered, but it is the alias label that is rendered instead.

How to Reproduce

conf.py:

project = "Thing"

extensions = (
    "sphinx.ext.autodoc",
    "sphinx.ext.autosummary",
    "sphinx.ext.napoleon",
)

autodoc_default_options = {
    "members": True,
}

autosummary_generate = True

HW_PROPS = "Hardware Properties"
napoleon_custom_sections = (
    (HW_PROPS, "params_style"),
    ("HwProps", HW_PROPS),
)

index.rst

API
===

.. autosummary::
    :toctree: autosummary
    :recursive:

    thing

thing.py

class Thing:
    """The thing

    HwProps:
        color (str): The color of the thing.
    """

We would expect the section header in the generated HTML documentation to be the original label Hardware Properties, but instead it is the alias label HwProps.

Environment Information

Platform:              linux; (Linux-6.1.0-25-amd64-x86_64-with-glibc2.36)
Python version:        3.12.2 (main, Mar 11 2024, 16:50:09) [GCC 12.2.0])
Python implementation: CPython
Sphinx version:        8.0.2
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

  • sphinx.ext.autodoc
  • sphinx.ext.autosummary
  • sphinx.ext.napoleon

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions