sphinx
sphinx copied to clipboard
Pass autosummary options to recursive template
Subject: Pass autosummary options to recursive template
Feature or Bugfix
- Bugfix
Purpose
- When using autosummary with
:recursive:, options like:nosignatures:were not passed, so that nested modules would not have them set. - This PR makes nested autosummaries inherit options from the root autosummary.
Detail
- Changed
find_autosummary_in_linesto parse:nosignatures:and add it toAutosummaryEntry - Pass those
AutosummaryEntryattributes which are actual options togenerate_autosummary_content. The expression to convert the entry to a dictionary while excluding some is a bit complex.NamedTuple._asdictis actually meant for public use (just underscored to avoid conflicts). An alternative would be to have an options dictionary (includingtemplateandrecursive) in AutosummaryEntry. I could have merged them intocontext, but decided against because it has a different purpose. - Changed the template to include the options. Here, I also included
:recursive:instead explicitly excluding it from the options dictionary. The for loop is maybe a bit too generalized. The idea is that options with boolean or falsy ("") values don't need to be printed, True options only include the name and for the rest name and value. - The Python whole file could benefit from reformatting with e.g. black.
Relates
- Resolves https://github.com/sphinx-doc/sphinx/issues/11994
@aeisenbarth could you edit the 'related bugs' section to use the phrasing 'Resolves #11994'? (this is an GitHub linked-issue indicator that auto-closes the referenced bug if/when a pull request is merged)