[autodoc] How to document private inner class?

5 views
Skip to first unread message

Ian Pilcher

unread,
Feb 6, 2023, 12:44:44 PM2/6/23
to sphinx...@googlegroups.com
Consider the module below.

sphinxtest.py:

"""A module to test Sphinx.

.. autoclass:: _Foo
:members:
:private-members:
"""

import enum

class _Foo(object):
"""A class to test Sphinx.

:param name: The name of the Foo.
:type name: str
"""

def __init__(self, name):
self.__name = name

# Name will be mangled to _Foo__Bar
class __Bar(enum.Enum):
"""A private inner class."""
BAZ = 1
"""Bar gonna baz."""

How can I get the __Bar inner class (whose name will be mangled to
_Foo__Bar) to be automatically documented? (I.e. the docstrings of both
the inner class and its member should be included in the generated
documentation.)

Currently, the generated documentation only includes this.

_Foo__Bar
alias of sphinxtest._Foo.__Bar

I have tried adding and additional autoclass directive to the module
docstring, but everything that I've tried has given me an error.

How am I supposed to do this?

--
========================================================================
Google Where SkyNet meets Idiocracy
========================================================================

Reply all
Reply to author
Forward
0 new messages