-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Support cython embedSignature
#134
Comments
Interesting, thanks for the request 🙂 So, we already have the I'd like to see an example of such rendered signatures + docstrings, could you show us that? A screenshot of your localhost:8000 docs would be just fine. |
Hi, working on the Cython project that sparked this issue and just wanted to give an update. Instead of the So with that, the documentation basically renders as expected, and I'd say if implementing special support for the The only caveat I noticed is that Cython is not able to preserve the function signature of special methods, for example So the only way to allow for displaying a default value would be to extract it directly from the parameter in the docstring.
Although I'd understand if you wouldn't want to include this functionality, since its a special fix and not really part of the google docstring syntax (not sure if numpy or sphinx would allow for something like this already). But I just wanted to share what I found out :) EDIT: An additional drawback however regarding |
Hey @multimeric, @tazend. I have looked at this again and decided to close as out of scope. Cython 3.0 seems to resolve most of the issue, leaving only Adding an option to consider the first line of a docstring to be a signature that should be parsed again and used instead of the real signature feels a bit heavy. Docstring styles are already quite complicated to support (their specs are generally under specified), so adding more custom logic is not appealing to me 😅 If we ever want to be able to specify default values in docstrings, it would have to re-use Python syntax (as it's the only way to parse it correctly in 100% of cases without having to re-implement a custom parser ourselves), something like: def __init__(self):
"""Summary.
Parameters:
param1: str | int = 0
Description of param1.
param2: list[Class] | None = None
Description of param2.
"""
... ...but this should be discussed in another issue, for example in this one: mkdocstrings/mkdocstrings#577 🙂 |
Is your feature request related to a problem? Please describe.
When using cython with the
embedSignature
option, the__doc__
of the function will have the function signature in the first line of the doc. This naturally results in confusing documentation downstream in mkdocs because the signature gets repeated and presented incorrectly.Describe the solution you'd like
I propose adding a new setting to all (?) docstring parsers along the lines of
cython_embed_signature: bool
, which, if true, will strip the first line from the docstring prior to parsing, and use it as the function signature instead of however it is done now.Describe alternatives you've considered
show_signature: False
improves the current documentation somewhat, but the signature is still formatted incorrectly.Additional context
The text was updated successfully, but these errors were encountered: