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 HTML markup to method/function return typehint #9225
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
643131a
Add HTML markup to the return type hint.
doerwalter cf2d5b3
Rename CSS classes for return type hint HTML markup.
doerwalter b079543
Add configuration option html_signaturereturn_icon for the arrow befo…
doerwalter 6af23a9
Fix typo.
doerwalter ac2eb03
Add version info for html_signaturereturn_icon.
doerwalter 798adc4
Add tests for html_signaturereturn_icon.
doerwalter 9aedeee
Remove configuration option html_signaturereturn_icon.
doerwalter File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why this is needed. Do you want to change the character of the allow?
Adding a new configuration increases the cost of maintenance. So I need to know this is really needed.
Note:
html_signaturereturn_icon
andhtml_signature_return_icon
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the typo.
Yes, I would like to be able to replace the arrow character.
My reason for this is that I would like to be able to display the function/method signature without the type hints. The type hints should however be displayed when the user hovers over an annotation icon with the mouse. This should work for both the parameter type hints and the return type hints. I would like to use consistent icons for this. For example https://fontawesome.com/icons/question-circle?style=regular for the parameter hint and https://fontawesome.com/icons/arrow-circle-right?style=regular for the return hint.
I find long signatures with type hints confusing. An extreme example from Sphinx (in
application.py
inSphinx
):IMHO it's hard to see at first glance what is a parameter name, what is a type annotation and what is a default value (even with syntax highlighting). Without the type annotations this look much better:
But I don't want to drop the type annotations completely, because they're useful when you are writing the function call. Fortunately on an HTML page we can have both: short and clear signatures and access to the type hints: By displaying the type hints on demand via a popup/tooltip.
I realize that this currently isn't possible for the parameter hint, but this patch makes it possible for the return hint.
I chose
html_signaturereturn_icon
for that name, because this matches the name forhtml_permalinks_icon
.However if we would introduce an icon for the parameter annotation in the future,
html_signature_return_icon
would make more sense, since we might havehtml_signature_param_icon
too.I'll start working on a testcase.
OK, I'll add a
.. versionadded:: 4.1
to the documentation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your explanation. I understand it is worthy for you. But, I don't think it's also worthy for other users. Is it possible to change the icon by CSS hack or JS?