mkdocstrings / pytkdocs

Load Python objects documentation.
https://mkdocstrings.github.io/pytkdocs
ISC License
50 stars 32 forks source link

pass context to parse_docstring #118

Closed jakekaplan closed 3 years ago

jakekaplan commented 3 years ago

The full context was not being passed to parse_docstring. This was not allowing Class signatures to be passed down for extra context and instead would only rely on the class docstring itself.

pawamoy commented 3 years ago

Hello @jakekaplan, thank you very much for your contribution!

Do you have an example of a docstring that would lack this context previously? Just for reference :slightly_smiling_face:

jakekaplan commented 3 years ago

Hi @pawamoy!

My use case was something like below:

class MyClass:
    """
    This is my class. 

    Args:
        num: this is a number.  
    """
    def __init__(num: int = 1):
        ...

I noticed that the defaults wouldn't populate for Classes unless i explicitly wrote them into the docstring. For methods this pattern was fine and the signature was used as a backup. Passing the context down allowed the signature to be used for Classes as well.

Please let me know if this is sufficient! And thank you for a great tool!

pawamoy commented 3 years ago

Thank you, that's exacty what I needed to fully understand the PR :slightly_smiling_face: Then it's all good, merging!

jakekaplan commented 3 years ago

@pawamoy thanks so much!

Just wondering, will this change make it's way into mkdocstrings?

pawamoy commented 3 years ago

Yes of course :) I'll release a new version soon