Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for short signatures in autosummary #13172

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

timhoffm
Copy link
Contributor

@timhoffm timhoffm commented Dec 6, 2024

This introduces a new :signatures: option to .. autosummary::.

Possible values are:

  • "long" (default) - same as the current default
  • "short": format functions and classes as func() if they do not have arguments and func(…) if they do have arguments.
  • "none": same as the already existing :nosignature:

The new functionality here is the "short" option. This allows to distinguish properties and attributes from functions and classes without costing a lot of space for a long signature.

Note1: Design: I've added the :signatures: option to have a single config value instead of :shortsignatures: alongside :nosignatures:. This is also more extensible in case other signature variants come up in the future. :nosignatures: remains available for backward compatibility, but :signatures: takes precedence if given.

Note 2: Tests: There are currently no tests for the signature formatting. I could add some tests for Autosummary.get_items, but I don't understand how to set up everything in a test so that I can exercise that function. Please give a hint how to do this if tests are desired.

Closes #13101.

get_items() already formats the signature. Handling :nosignatures: option in the saves the signature computation cost if the signature is not wanted. Also, this prepares for more complex signature options.
This is in preparation of extending singature formating.
@timhoffm timhoffm force-pushed the autosummary-short-signature branch from b87c5bc to cd95331 Compare December 7, 2024 07:55
This formats functions and classes with (…) if they have
arguments and () if they don't have arguments. This makes
it easier to distinguish callables from attributes and
properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Short signatures for autosummary
1 participant