Pydoc-Markdown

4.8.2 · maintenance · verified Thu Apr 16

Pydoc-Markdown is a tool that generates Python API documentation in Markdown format by parsing Python code using the `docspec` library. It supports multiple documentation styles, including Sphinx, Google, and its own specific format. While the project is still actively maintained with recent releases, the maintainer suggests considering `mkdocstrings` for new projects due to limited time for proper maintenance and development. The current stable version is 4.8.2.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to generate Markdown API documentation for a simple Python module. It involves creating a Python file, defining a `pydoc-markdown.yml` configuration to specify the module and output, and then running the `pydoc-markdown` CLI command. The output is redirected to `API.md`.

mkdir my_project
cd my_project

# Create a sample Python module
cat << EOF > my_module.py
"""A simple example module."""

def greet(name: str) -> str:
    """Greets a person by name.

    :param name: The name of the person to greet.
    :returns: A greeting string.
    """
    return f"Hello, {name}!"

class MyClass:
    """A sample class.

    :ivar value: An example instance variable.
    """
    def __init__(self, value: int):
        self.value = value

    def get_value(self) -> int:
        """Returns the stored value."""
        return self.value
EOF

# Create a pydoc-markdown.yml configuration file
cat << EOF > pydoc-markdown.yml
loaders:
  - type: python
    search_path: [.]
renderer:
  type: markdown
  pages:
    - title: My API
      contents:
        - 'my_module'
EOF

# Generate the documentation
pydoc-markdown --config pydoc-markdown.yml > API.md

# To view the generated Markdown (optional)
# cat API.md

view raw JSON →