A Sphinx extension for rendering terminal input and output.
Project description
sphinx-terminal
sphinx-terminal allows you to display terminal input and output in your Sphinx documentation.
Basic usage
To display terminal input and output in your Sphinx document, use the terminal
directive, providing input and output as follows:
.. terminal::
input
output
Input can span multiple lines, as long as the lines are in the same paragraph. Everything after the first blank line in the directive's body is rendered as output.
The prompt defaults to user@host:~$. To customize this, use the :user:, :host:,
and :dir: options.
.. terminal::
:user: author
:host: canonical
:dir: ~/path
echo 'hello'
hello
To render only the output of a command, include the :output-only: flag in the
directive's options.
.. terminal::
:output-only:
This is rendered as output.
To enable a copy button for users, include the :copy: flag as a directive option.
Only the input can be copied.
.. terminal::
:copy:
echo 'hello'
hello
Similarly, to make the output scrollable, include the :scroll: flag as a directive
option.
.. terminal::
:scroll:
echo 'hello'
hello
Project setup
sphinx-terminal is published on PyPI and can be installed with:
pip install sphinx-terminal
After adding sphinx-terminal to your Python project, update Sphinx's conf.py file to include sphinx-terminal as one of its extensions:
extensions = [
"sphinx_terminal"
]
The copy button functionality depends on sphinx-copybutton. sphinx-terminal automatically adds this extension to your Sphinx project and configures it to copy terminal input and ignore the multiline prompt.
copybutton_selector = "span.copybutton, div:not(.terminal-code) > div.highlight > pre"
copybutton_prompt_text = "> |"
copybutton_prompt_is_regexp = True
Customizing these configurations in your conf.py file overrides the defaults assigned by sphinx-terminal.
Community and support
You can report any issues or bugs on the project's GitHub repository.
If you're interested in contributing, start with the contribution guide.
sphinx-terminal is covered by the Ubuntu Code of Conduct.
License and copyright
sphinx-terminal is released under the GPL-3.0 license.
© 2025 Canonical Ltd.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_terminal-1.0.3.tar.gz.
File metadata
- Download URL: sphinx_terminal-1.0.3.tar.gz
- Upload date:
- Size: 95.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a5ae9d20f5e9fd96d7df753e62b5415e33816a4833b73fcd8d60afee4695cbb
|
|
| MD5 |
49569697d93d38bd7796bc5f0b93506c
|
|
| BLAKE2b-256 |
e6f7c48cfa302ba9e82687972334b1995e687cab79999a1805cb3d96d67b80dd
|
Provenance
The following attestation bundles were made for sphinx_terminal-1.0.3.tar.gz:
Publisher:
release-publish.yaml on canonical/sphinx-terminal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_terminal-1.0.3.tar.gz -
Subject digest:
7a5ae9d20f5e9fd96d7df753e62b5415e33816a4833b73fcd8d60afee4695cbb - Sigstore transparency entry: 735553503
- Sigstore integration time:
-
Permalink:
canonical/sphinx-terminal@570209d38e9068cd6963247183af6e9f0e0405d6 -
Branch / Tag:
refs/tags/1.0.3 - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-publish.yaml@570209d38e9068cd6963247183af6e9f0e0405d6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_terminal-1.0.3-py3-none-any.whl.
File metadata
- Download URL: sphinx_terminal-1.0.3-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
127ca5f21d4a4880bb5f8d18e7114f89d66f96df425478fb376376697e8315ac
|
|
| MD5 |
fd8457bb0f5d3244f225309f935540b2
|
|
| BLAKE2b-256 |
4b096afb984b5b58f6d522dea00f59b19ffa2405fb72b298803f51ac3df0f31d
|
Provenance
The following attestation bundles were made for sphinx_terminal-1.0.3-py3-none-any.whl:
Publisher:
release-publish.yaml on canonical/sphinx-terminal
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_terminal-1.0.3-py3-none-any.whl -
Subject digest:
127ca5f21d4a4880bb5f8d18e7114f89d66f96df425478fb376376697e8315ac - Sigstore transparency entry: 735553508
- Sigstore integration time:
-
Permalink:
canonical/sphinx-terminal@570209d38e9068cd6963247183af6e9f0e0405d6 -
Branch / Tag:
refs/tags/1.0.3 - Owner: https://github.com/canonical
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
self-hosted -
Publication workflow:
release-publish.yaml@570209d38e9068cd6963247183af6e9f0e0405d6 -
Trigger Event:
push
-
Statement type: