Skip to content

New hook to customize base list #3014

Closed
@wheerd

Description

@wheerd
Contributor

I would like to change the formatting of the base list for classes. Specifially I would like to provide information about parameterized types (e.g. Dict[str, int]). See agronholm/sphinx-autodoc-typehints#8 for how I want to use it.

For that I need a new hook/event similar to the existing autodoc-process-signature. I propose the signature autodoc-process-bases(app, what, name, obj, options, formatted_bases). The first five arguments are exactly the same as for the existing events. The last one is the list of formatted strings generated in add_directive_header for the bases. It can be modified to change what is output. Alternatively, to provide even more freedom, the hook can return a string. This string is then inserted instead of the "Bases: ..." line.

I can provide an implementation in a pull request, if you like the idea.

Activity

added this to the 4.1.0 milestone on Mar 27, 2021
added a commit that references this issue on May 15, 2021

Close sphinx-doc#3014: autodoc: Add autodoc-process-bases

44f6f70
added a commit that references this issue on May 15, 2021

Close sphinx-doc#3014: autodoc: Add autodoc-process-bases

67db20d
added a commit that references this issue on May 17, 2021

Merge pull request #9233 from tk0miya/3014_autodoc-process-bases

b19dc36
locked as resolved and limited conversation to collaborators on Jul 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tk0miya@wheerd

        Issue actions

          New hook to customize base list · Issue #3014 · sphinx-doc/sphinx