views:

365

answers:

3

I am using Sphinx for documenting my python project. I have the autodoc extension enabled and have the following in my docs.

.. autoclass:: ClassName
   :members:

The problem is, it only documents the non-private methods in the class. How do I include the private methods too.

+1  A: 

Have you tried using a custom method for determining whether a member should be included in the documentation, using autodoc-skip-member?

Vinay Sajip
A: 

Here's a hint: imagine that private means "secret".

That's why Sphinx won't document them.

If you don't mean "secret", consider changing their names. Avoid using the single-leading-underscore name in general; it doesn't help unless you have a reason to keep the implementation secret.

S.Lott
This seems backwards to what PEP-8 says about private. "If in doubt, choose non-public" http://www.python.org/dev/peps/pep-0008/
svrist
@svrist: Not backwards -- that's the exact point. Sphinx won't document non-public. If you choose non-public, you don't get automatic documentation. If you want documentation, on the other hand, don't choose non-public. Here, "doubt" means you have a good reason for both and can't decide. If you don't have a *good* reason for non-public, you don't have "doubt", either. Make it public unless you have a *good* reason for non-public.
S.Lott
+1  A: 

No, private means private to the class and that it shouldn't be used from the public API. It's not meant to mean secret and for those of us wishing to use sphinx for full documentation of classes, excluding private methods is rather annoying.

The previous answer is correct. You will have to use a custom method as Sphinx does not currently support autodoc in conjunction with private methods.

df