-
Notifications
You must be signed in to change notification settings - Fork 32
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
Fix styling of punctuation in signatures #77
Conversation
I think this is the simplest fix --- we just need to make sure it doesn't inadvertently break something else. |
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 don't think that adding mypy to intersphinx config settings will allow hyperlinking abstracted |
I can confirm this PR fixes #76 for me. I see no side effects in my docs. Thanks! Also, the |
The issue with hyperlinking Tuple, Dict and other types defined by the typing module is simply that they are defined in the typing module. In the TensorStore docs I have monkey patched the Python domain xref resolution to handle these as a special case. |
@2bndy5 I think that's a bug in Sphinx. Notice, I noticed something similar in my docs and added the def autodoc_process_signature(app, what, name, obj, options, signature, return_annotation):
signature = modify_type_hints(signature)
return_annotation = modify_type_hints(return_annotation)
return signature, return_annotation
def modify_type_hints(signature):
if signature:
# Ensure types from the typing module are properly hyperlinked
for type_name in ["Tuple", "List", "Sequence", "Dict", "Optional", "Union", "Iterator", "Type", "Literal"]:
signature = signature.replace(f"{type_name}[", f"~typing.{type_name}[")
signature = signature.replace("~typing.~typing", "~typing")
return signature
def setup(app):
app.connect("autodoc-process-signature", autodoc_process_signature) |
Jinx... lol |
I found that in functions and methods, |
Fixes #76.