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

Docstring of base class' __init__ included #58

Closed
lilyminium opened this issue Nov 5, 2021 · 2 comments · Fixed by #61
Closed

Docstring of base class' __init__ included #58

lilyminium opened this issue Nov 5, 2021 · 2 comments · Fixed by #61
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@lilyminium
Copy link
Contributor

Thanks for creating this package, @mansenfranzen -- it's the missing link between the self-documenting objects of Pydantic and, well, actual documentation!

However, I'm not sure I've set it up correctly. Might you know why the class docstrings I'm getting have the Pydantic BaseModel docstring attached? e.g. here: https://psiresp.readthedocs.io/en/latest/_autosummary/psiresp.job.Job.html#psiresp.job.Job

If you look at the source, it includes the first part only:

https://psiresp.readthedocs.io/en/latest/_modules/psiresp/job.html#Job

Is it because I'm using autosummary instead of autopydantic_model or similar?

@mansenfranzen mansenfranzen added the documentation Improvements or additions to documentation label Nov 6, 2021
@mansenfranzen
Copy link
Owner

Thanks for reporting this. It is indeed an odd behaviour.

It has nothing to do with autosummary because this simply generates the autopydantic_model directive. Instead, I believe the reason is located in your conf.py which sets autoclass_content = 'both'. This tells sphinx autodoc to concatenate both the class doc string and its __init__ doc string in the class' documentation (see here). The psiresp.job.Job class inherits its __init__ from pydantic.BaseModel hence you see the doc string from pydantic's BaseModel. Could you please check if it disappears if you set autoclass_content = 'class'?

I guess you might not be the first or the last who stumbles across this. Describing this could be a good candidate for the documentation's FAQ section. If you want feel free to add a PR. Otherwise I can do it.

@mansenfranzen mansenfranzen changed the title Docstring of base class included Docstring of base class' __init__ included Nov 6, 2021
@lilyminium
Copy link
Contributor Author

That did the trick, thank you @mansenfranzen! (https://psiresp--37.org.readthedocs.build/en/37/_autosummary/psiresp.job.Job.html#psiresp.job.Job)

I'm happy to put up a PR today.

@mansenfranzen mansenfranzen linked a pull request Nov 9, 2021 that will close this issue
@mansenfranzen mansenfranzen added this to the v.1.5.1 milestone Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants