Skip to main content

Create Python API documentation in Markdown format.

Project description

Pydoc-Markdown

CircleCIVersion 3.x

Pydoc-Markdown is a tool to create Python API documentation in markdown format based on lib2to3.

Features

  • Parses the AST instead of running your code
  • Understands multiple documentation styles (Sphinx, Google, Pydoc-Markdown)
  • Resolves cross-references of the form #PetType.CAT
  • Supports attribute docstrings (#: ... before or string literals after the statement)

On the roadmap

  • Mkdocs integration (for feature parity with Pydoc-Markdown 2.x)
  • Support for images (#94)
  • Understand fixmes and hints in the source code (eg. # doc: ignore)
  • Cross-page (and cross-project) links in API documentation

Usage

Pydoc-Markdown 3 is not currently available on PyPI. To install the current development version, you can simply pass the Git repository URL to Pip. It is recommended to install Pydoc-Markdown in isolation with Pipx.

$ pipx install git+https://github.com/NiklasRosenstein/pydoc-markdown.git@develop

This makes the pydoc-markdown command available in your command-line.

On the CLI you specify either the name of a configuration file or provide a YAML formatted configuration. If you do not specify any arguments, the default configuration file is loaded (pydoc-markdown.ya?ml).

$ pydoc-markdown [<config>]

The configuration is composed of three main components: A list of loaders, a list of documentation processors and a renderer. The default configuration is defined as follows:

loaders:
  - type: python
processors:
  - type: filter
  - type: smart
  - type: crossref
renderer:
  - type: markdown

It is automatically applied when using the Pydoc-Markdown CLI to render Markdown documentation for Python modules on the fly (without a YAML configuration file). Example:

$ cat <<EOF >a.py
def say_hello(name: str):
  """ Says hello to the person specified with *name*.

  :param name: The person to say hello to.
  :raises ValueError: If *name* is empty.
  :returns: Nothing """
  # ...
EOF
$ pydoc-markdown -m a -I .
Expand to see the generated Markdown

a

say_hello

say_hello(name: str)

Says hello to the person specified with name.

Arguments:

  • name: The person to say hello to.

Raises:

  • ValueError: If name is empty.

Returns:

Nothing


To jumpstart your documentation endavours, try running pydoc-markdown --bootstrap or pydoc-markdown --bootsrap-mkdocs to generate a template configuration file.

If a configuration file exists, then the CLI needs to be invoked without arguments, or with one argument that specifies the path to the configuration file. When using the mkdocs renderer, you may add the --watch-and-serve and --open arguments for smooth live-feedback.

$ pydoc-markdown ./pydoc-markdown.yaml -wo

lib2to3 Quirks

Pydoc-Markdown doesn't execute your Python code but instead relies on the lib2to3 parser. This means it also inherits any quirks of lib2to3.

List of known quirks

  • A function argument in Python 3 cannot be called print even though it is legal syntax

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydoc-markdown-3.0.0.tar.gz (25.5 kB view details)

Uploaded Source

File details

Details for the file pydoc-markdown-3.0.0.tar.gz.

File metadata

  • Download URL: pydoc-markdown-3.0.0.tar.gz
  • Upload date:
  • Size: 25.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.10

File hashes

Hashes for pydoc-markdown-3.0.0.tar.gz
Algorithm Hash digest
SHA256 245371dc7c111033067326cb829507f8bf7dfff3f136e10494dd059afc44163b
MD5 5a15a48bc32ef9429d455a4718ba6338
BLAKE2b-256 5fe87e337fdc72f7e874857867f843f2750c3fd95f9d4cf42a2091ac0159a669

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page