0

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.

3
  • 2
    Example code please? Commented Oct 14, 2014 at 8:33
  • 1
    Instance methods, class methods, static methods? Leading-underscore method names? Any decorators involved? Commented Oct 14, 2014 at 8:37
  • Yes. There are instance methods, class methods, leading_underscore methods, and decorators as well. Commented Oct 14, 2014 at 9:32

1 Answer 1

1

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.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.