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

__init__ methods do not get parsed by Sphinx autodoc #26

Closed
DanielKotik opened this issue Jul 1, 2021 · 4 comments
Closed

__init__ methods do not get parsed by Sphinx autodoc #26

DanielKotik opened this issue Jul 1, 2021 · 4 comments

Comments

@DanielKotik
Copy link
Contributor

Looks good.
I think the docstring in models.ISModel is not rendering correctly due to some incorrect formatting... But even if it were rendering there would the same error as we saw in PRs #18 and #16. I will fix later today.

Mhh, for me this docsting looks good. Also, there are now warning messages anymore.

Strange there are no warnings, but I don't see any of the class parameters displaying? And the propertys have no docs

Screenshot from 2021-06-28 12-02-10

Originally posted by @timcallow in #19 (comment)

@DanielKotik DanielKotik changed the title __init__ method do not get parsed by Sphinx autodoc __init__ methods do not get parsed by Sphinx autodoc Jul 1, 2021
@timcallow
Copy link
Contributor

@DanielKotik I'm not sure we want __init__ methods to be parsed. In other parts of the code I used the convention of documenting not inside __init__ but rather directly after the class first line. I think it would be better to modify the ISModel class to reflect the convention elsewhere and it will all work out (actually I already started doing this locally, will push soon...)

@DanielKotik
Copy link
Contributor Author

Yeah, this is the easiest solution. It is also more reasonable to do it within the class docstring as we have done it at some other classes already - being consistent is a good thing. Attributes, however, may still be documented inline, i.e. within the __init__ method as demonstrated here. While having a docstring of __init__ if fully compliant with Numpy's docstring style convention, Sphinx autodoc seems to treat __init__ magic methods special - sure for good reason (I will figure out why).

@DanielKotik
Copy link
Contributor Author

Setting autoclass_content to "both" in conf.py concatenates the class’ and the __init__ method’s docstring. It is somehow weird to set this explicitly, because here Sphinx docs says ...Sphinx’s default behavior, which considers the __init__ docstring as part of the class documentation.

grafik

However, as we already agreed on documenting the parameters directly inside the class docstring, I will leave it as is.

@DanielKotik
Copy link
Contributor Author

@timcallow You can close this issue, when you have read my above comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants