exAres
exAres

Reputation: 4926

Why some docstrings of methods in class are not shown in pydoc?

I am using pydoc to create documentation. But it is only displaying the docstring for a class and for methods such as __init__. Is there any parameter to be passed to pydoc to create a documentation for each method of a class as well?

Example:

class myclass(some_other_class):
    """
    This is 'class' docstring.
    """

    def __init__(self):
       """
       This is docsctring for __init__ method.
       """
       pass

    def mymethod(self, some_parameter):
       """
       This is docstring for mymethod function.
       """
       pass

Now when I use pydoc on this code, I do not see "This is docstring for mymethod function." in the output generated.

Upvotes: 0

Views: 1179

Answers (1)

Flavian Hautbois
Flavian Hautbois

Reputation: 3060

Your code looks perfectly fine, I put it in a script.py file, removed the "some_other_class" reference, and ran python -m pydoc -w script. It generated the following HTML:

class myclass
      This is 'class' docstring.

      Methods defined here:
          __init__(self)
            This is docsctring for __init__ method.
          mymethod(self, some_parameter)
            This is docstring for mymethod function.

Upvotes: 1

Related Questions