-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
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.
- object type
data
has no variabledatas
- custom object types like
pydantic_model
cannot be selected separately. The approach of taking the rest (members
minus all type lists) would combine objtypepydantic_model
withdata
because both are in no existing list. But data cannot be handled as the same.
See: Support for autosummary :recursive: documentation of entire API mansenfranzen/autodoc_pydantic#33 (comment)
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 allobjtype
s found by the documenter. For each found type, add it as a key tons
and expose it to templates. - Drop the
all_…
variables. Read all public items into a singlepublic
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)) .