0

I understand how Python docstrings work and I regularly use pydoc.render_doc to access function docstrings. However, I don't know how to use render_doc to access the help topics, e.g. help("UNARY"). I don't even know where such a docstring would exist. Is there a way to either a) access help topics with pydoc or b) an alternative way to capture the help text in a variable?

help("UNARY")                         # prints help to console
import pydoc
pydoc.help("UNARY")                   # prints help to console
test = pydoc.render_doc("str")        # writes help to variable

test = pydoc.render_doc("UNARY")      # ERROR
pydoc.help("UNARY")                   # prints help to console
test = pydoc.help("UNARY")            # prints help to console, 'test' is empty
mikeck
  • 3,534
  • 1
  • 26
  • 39

1 Answers1

1

pydoc will work in commandline. Use the below command to generate the html documentation for the python modules in the current location.

C:>python -m pydoc -w sys wrote sys.html

But pydoc command cannot be used for Keywords and topics

Refer https://svn.python.org/projects/sandbox/trunk/setuptools/pydoc.py to know the list of topicss and keywords.

Rosy
  • 41
  • 1
  • 6
  • This doesn't answer my question. I'm looking for a way to capture the help text in a variable. I don't need a way to get the list of topics and I don't see how running pydoc in the command line helps, especially since you say it can't be used with keywords and topics. – mikeck Jul 25 '17 at 07:14