Sphinx Prompt

1.10.2 · active · verified Sun Apr 12

Sphinx Prompt is a Sphinx directive that allows developers to add code blocks with unselectable prompts to their documentation. This ensures that readers can easily copy and paste commands without including the prompt characters. The library is actively maintained, with frequent minor releases, and is currently at version 1.10.2.

Warnings

Install

Imports

Quickstart

After installing the library and adding 'sphinx_prompt' to your `conf.py` extensions, you can use the `.. prompt::` directive in your reStructuredText files. You can specify a language (e.g., `python`, `bash`, `powershell`) and a custom prompt. If no prompt is given for a shell language, a default is used (e.g., `$` for bash, `C:\>` for batch, `PS C:\>` for powershell).

# conf.py
extensions = [
    'sphinx_prompt',
]

# my_document.rst

.. prompt:: python

   >>> import sys
   >>> print(sys.version)
   3.11.0 (main, ...)

.. prompt:: bash $

   $ ls -l
   total 0
   -rw-r--r-- 1 user group 0 Jan  1 10:00 myfile.txt

view raw JSON →