Sphinx Program Output Extension

0.19 · active · verified Thu Apr 16

sphinxcontrib-programoutput is a Sphinx extension that enables the literal insertion of arbitrary command output into documentation. This helps maintain up-to-date command examples. The current version is 0.19, with releases occurring on an irregular but active cadence, most recently in February 2026.

Common errors

Warnings

Install

Imports

Quickstart

After installation, enable the extension by adding 'sphinxcontrib.programoutput' to the `extensions` list in your Sphinx `conf.py`. Then, use the `.. program-output::` or `.. command-output::` reStructuredText directives in your documentation files to include command output. `command-output` mimics a shell session, including the command itself. Options like `cwd` (current working directory), `ellipsis` (to shorten output), `nostderr` (to hide stderr), `shell` (to pass command to system shell), and `returncode` (to expect specific exit codes) are available.

# conf.py
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinxcontrib.programoutput'
]

# Your_Document.rst

.. program-output:: python -V
   :shell:

.. command-output:: python -c "print('Hello from Python!')"

# Example with options
.. program-output:: git log -1
   :cwd: .
   :ellipsis: 2,-1

view raw JSON →