How to generate automatically docs for the c_nested
function?
Background: I do code documentation for other developers and I would like to automatically generate a summary of all class methods included nested functions with short description (docstring).
When I run help(A)
on class A
I get:
Help on class A in module __main__:
class A(builtins.object)
| A(a)
|
| doc A
|
| Methods defined here:
|
| __init__(self, a)
| Initialize self. See
|
| b_method(self)
| doc b_method
Requested output: c_nested()
with docstring: (Docs could be printed event with script, it doesn't need to be printed with pydoc help.)
Help on class A in module __main__:
class A(builtins.object)
| A(a)
|
| doc A
|
| Methods defined here:
|
| __init__(self, a)
| Initialize self. See
|
| b_method(self)
| doc b_method
|
| c_nested()
| doc c_nested
Class example:
class A:
""" doc A """
def __init__(self,a):
self.a = a
def b_method(self):
""" doc b_method """
def c_nested():
"""doc c_nested """
pass
return c_nested()
Local functions are not publicly visible, so their docstring won't be included in the help.
If you want the function to be shown in the help, make it a module-level function or a method of the class.
See also Are docstrings for internal functions (python) necessary?