Adding magic methods

Anonymous avatarAnonymous created an issue

Enhancement reason: I tried making documentation for a project and found out the sphinx didn't show methods such as init, len.

Enhancement: After som diggin in the autodoc.py file I found out these methods aren't documented cause of this line:

Line 538:

if want_all and membername.startswith('_'):
      # ignore members whose name starts with _ by default
      skip = True

Basicly is hides privatemethods but also magic methods.

My hack to that is:

magic_functions = ['__str__',
                              '__init__',
                              '__len__',
                               '__lt__',
                               '__eq__',
                               '__ne__',
                               '__ge__',
                               '__gt__',
                               '__le__',
                               '__repr__',
                               '__iter__' 
                               ]
if want_all and membername.startswith('_') and not membername in magic_functions:

Alternatively the hack could be made differently by just testing if a mether starts and ends with ''. This would be better under the assumption people don't use the magic method naming scheme on private methods.

This also solves the no constructor method documentation, and the issue http://bitbucket.org/birkenfeld/sphinx/issue/176/provide-option-to-include-private-and-special.

Comments (3)

  1. Daniel Neuhäuser

    These are by far not all special methods(that's what they are called by the documentation). I think we should differ between methods starting with _ and methods enclosed by like foo. Both variants should be documented if the user supplies an option like :private-members:/:special-members:

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.