On this page
  1. pydoc
  2. Import
  3. Overview
  4. Quick Start
  5. Implementation Walkthrough
  6. 1. Generating Offline HTML or CLI Reference Docs
  7. Gotchas & Boundaries
  8. Common Functions
  9. Examples & Notes

pydoc

Prev: pyclbr | Up: stdlib_module | Next: pydoc_data
Rel: typing, annotationlib, pydoc_data, doctest, unittest
Ref: docs.python.org — pydoc
Tags: #public #python3 #stdlib


Import

import pydoc

Overview

Python's built-in documentation generator (python3 -m pydoc, pydoc.render_doc(), pydoc.doc(), and the interactive help() system). Use pydoc from the CLI to browse installed package docs offline or start a local documentation browser (python3 -m pydoc -b), or programmatically to render plain-text/HTML docstrings.

Quick Start

import pydoc

plain = pydoc.render_doc("math", renderer=pydoc.plaintext)
assert "FUNCTIONS" in plain and "sqrt(" in plain

Implementation Walkthrough

1. Generating Offline HTML or CLI Reference Docs

Common CLI workflows:

Gotchas & Boundaries

Common Functions

Examples & Notes

Generate and view documentation from docstrings (python3 -m pydoc <name>):

def calculate_total(amounts):
    """
    :param amounts: The list of amounts
    :return: The grand total
    """
    return sum(amounts)

Linked from

Related notes