Expose complete objtype information to autosummary templates #12048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Subject: Create autosummary template variables dynamically based on
objtype
from documenters, enabling custom object types likepydantic_model
to be selectable in templates (#12021, mansenfranzen/autodoc_pydantic#33).Feature or Bugfix
Purpose
The templates and template variables in autosummary expose only a hard-coded set of object types like (
classes
for object typeclass
) and the templates.As a consequence, it is not possible to add custom sections for custom object types to the template, because one can not select/distinguish the custom type from the available types. Custom object types are provided for example by autodoc-pydantic. It works only with one level of autosummary which then uses the base template with directive
.. auto{{ objtype }}::
(with objtype =pydantic_model
). However, this is not possible with:recursive:
because then the module template is used which contains no section for the custom type.The current recommendation is to fork autosummary (mansenfranzen/autodoc_pydantic#33 (comment)).
Detail
This PR aims to avoid forking and proposes different template variables. I do not request to merge this, but it is a basis for discussion.
Changes:
objtype
and exposed as variables with exactly that object type. This makes the implementation more generic and open to new object types, but also drops repetitive code.Questions:
members_{objtype}
.test_autosummary_generate_content_for_module_with_pydantic
?Relates