sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Pass autosummary options to recursive template

Open aeisenbarth opened this issue 1 year ago • 1 comments

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_lines to parse :nosignatures: and add it to AutosummaryEntry
  • Pass those AutosummaryEntry attributes which are actual options to generate_autosummary_content. The expression to convert the entry to a dictionary while excluding some is a bit complex. NamedTuple._asdict is actually meant for public use (just underscored to avoid conflicts). An alternative would be to have an options dictionary (including template and recursive) in AutosummaryEntry. I could have merged them into context, 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 avatar Feb 21 '24 17:02 aeisenbarth

@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)

jayaddison avatar Feb 23 '24 09:02 jayaddison