How can I use Sphinx' Autodoc-extension for private methods? How can I use Sphinx' Autodoc-extension for private methods? python python

How can I use Sphinx' Autodoc-extension for private methods?


if you are using sphinx 1.1 or above, from the sphinx documentation site at http://www.sphinx-doc.org/en/master/ext/autodoc.html,

:special-members::private-members:


You can add this to conf.py file:

autodoc_default_flags = ['members', 'undoc-members', 'private-members', 'special-members', 'inherited-members', 'show-inheritance']


One way to get around this is to explicitly force Sphinx to document private members. You can do this by appending automethod to the end of the class level docs:

class SmokeMonster(object):   """   A large smoke monster that protects the island.   """   def __init__(self,speed):      """      :param speed: Velocity in MPH of the smoke monster      :type  speed: int      .. document private functions      .. automethod:: _evaporate      """      self.speed = speed   def _evaporate(self):      """      Removes the smoke monster from reality. Not to be called by client.      """      pass