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 an option for displaying short Literal types #11109

Merged
merged 1 commit into from Apr 5, 2023

Conversation

AA-Turner
Copy link
Member

Closes #9643

cc: @jbms

A

@jbms
Copy link
Contributor

jbms commented Jan 7, 2023

Thanks for implementing this.

I think just the Python domain changes are needed, and the autodoc changes should be skipped, since I think it introduces an ambiguity with string literals and it is not clear to me what purpose it serves. I think it is better to always pass valid Python syntax to the Python domain directives, and just do this transformation when converting to docutils nodes.

@AA-Turner AA-Turner force-pushed the short-literals branch 3 times, most recently from a2de47c to 29b789b Compare April 5, 2023 01:22
The new ``python_display_short_literal_types`` configuration option
for the ``py`` domain controls display of PEP 586 ``Literal`` types.
The 'short' format is inspired by PEP 604, using the bitwise OR operator
to distinguish the possible legal values for the argument.
@AA-Turner
Copy link
Member Author

@jbms How's this much simpler implementation?

A

@jbms
Copy link
Contributor

jbms commented Apr 5, 2023

Looks good to me, thanks!

@AA-Turner AA-Turner changed the title Add short literal display Add an option for displaying short Literal types Apr 5, 2023
@AA-Turner AA-Turner merged commit 4a3febb into sphinx-doc:master Apr 5, 2023
22 checks passed
@AA-Turner AA-Turner added this to the 6.2.0 milestone Apr 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2023
@AA-Turner AA-Turner deleted the short-literals branch May 12, 2023 21:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sphinx.domains.python._parse_annotation should improve formatting of Union, Optional, Literal, constants
2 participants