Skip to content

In autosummary, expose complete objtype information to templates #12021

@aeisenbarth

Description

@aeisenbarth

Is your feature request related to a problem? Please describe.
When using autodoc_pydantic with recursive autosummary, I must edit the template so that it documents items with objtype pydantic_model. The problem is that there is no way to properly select only this object type.

Templates have no access to objtype of an item. The only way to distinguish items by type is to use the variables available in templates, that sort items into some hand-crafted lists. However, this is unreliable because the provided variables don't cover every object type.

Describe the solution you'd like

It would be nice to have a more generalized approach.

I would like to propose:

  • Drop the hard-coded lists functions, classes etc. in sphinx.ext.autosummary.generate:generate_autosummary_content but create dynamic lists for all objtypes found by the documenter. For each found type, add it as a key to ns and expose it to templates.
  • Drop the all_… variables. Read all public items into a single public list. This is simpler and works better with the above generalization. Templates can combine both like {{ for item in classes if item in public }}.

Describe alternatives you've considered

Forking and copy-pasting the source code of autosummary as a custom sphinx extension (see: mansenfranzen/autodoc_pydantic#33 (comment)) .

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions