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

Options to document private/special methods #121

Closed
wants to merge 5 commits into from

Conversation

ConorMacBride
Copy link
Member

Implements two new options for enabling the documenting of private and/or special methods. Only enabled for class names listed in config file. Class names must be given in full, e.g., module.submodule.classname. These options are useful for including private/special methods of base classes in documentation intended for new developers. This helps a new developer quickly create a new subclass, which makes use of, or overrides, private methods in the base class.

  • automodsumm_private_methods_of
    Should be a list of fully qualified names of classes where all of its
    private methods (i.e., method names beginning with an underscore, but
    not ending with a double underscore) should be documented. Defaults to [].

  • automodsumm_special_methods_of
    Should be a list of fully qualified names of classes where all of its
    special methods (i.e., method names beginning with a double underscore and
    ending with a double underscore) should be documented. Defaults to [].

Two new test cases are included, ensuring that each option only includes methods (either private or special) for the specified class names. Also ensures that the new options do not enable in the inclusion of extra private/special attributes.

Base automatically changed from master to main March 9, 2021 20:00
@ConorMacBride
Copy link
Member Author

Just rebased this. Failures are due to past sphinx versions not having docutils<0.18 specified: sphinx-doc/sphinx#9777. This also causes issues for the RTD build which by default installs older sphinx<2.

@og113
Copy link

og113 commented Apr 4, 2023

I see that this pull request is fairly old but just wanted to say that I'd really appreciate this functionality.

@bsipocz
Copy link
Member

bsipocz commented Apr 12, 2023

@ConorMacBride - would you mind rebasing the PR to check on how far it's from getting ready for review?

Add config value to enable documenting private methods of a specific list of classes.

Signed-off-by: Conor MacBride <conor@macbride.me>
Add config value to enable documenting special methods of a specific list of classes.

Signed-off-by: Conor MacBride <conor@macbride.me>
Signed-off-by: Conor MacBride <conor@macbride.me>
Signed-off-by: Conor MacBride <conor@macbride.me>
@ConorMacBride
Copy link
Member Author

I rebased and added a commit to remove PyPI codecov, but that should be a separate PR. I don't like how these new options are configured. I think it would be better if the classes were set within the directives in the rst files, and not listed in conf.py. I couldn't find a way to do that when I opened this PR. Also, it might be good to be able to apply these options to a whole module or the whole package, but currently I think it will only take a list of classes.

@bsipocz
Copy link
Member

bsipocz commented Apr 13, 2023

Would you mind to open that separate PR for codecov, or shall I? I don't expect anything else failing on main, but cron is rather infrequent, so who knows.

@ConorMacBride
Copy link
Member Author

I've opened #163 to remove codecov. py310-test-sphinxdev is failing there also.

@bsipocz
Copy link
Member

bsipocz commented Apr 13, 2023

I had a quick look in the other open PRs, and wonder how this would be another approach for this same problem? #103

@ConorMacBride
Copy link
Member Author

#103 would have worked for my use case, although I think my need to document private methods was due to bad API design! I think #103 is more useful and should be merged instead. @og113, would that also work for you? (specifying a global list of method names to include that begin with _)

@og113
Copy link

og113 commented Apr 19, 2023

A global list of method names that begin with an underscore to document would work for me, yes. But, does #103 explicitly exclude the possibility of documenting __init__ or __call__? If so, can __init__ and __call__ be documented with a separate option/method?

@pllim
Copy link
Member

pllim commented Apr 20, 2023

@bsipocz , does #165 also supersede this? Thanks!

@bsipocz
Copy link
Member

bsipocz commented Apr 20, 2023

yes, if Conor and og113 are happy with that as an alternative, we could close this one at merge time.

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

Successfully merging this pull request may close these issues.

None yet

4 participants