Sphinx "runcmd" extension
Project description
SphinxContrib RunCmd
Sphinx RunCmd aims to allow you to place the output of arbitrary commands in your rst files, while also giving you greater flexibility in how the output is formatted.
Installation
sphinxcontrib-runcmd is available on PyPI. To install:
$ pip install sphinxcontrib-runcmd
Add runcmd to your Project
First you'll want to add sphinxcontrib.runcmd to your conf.py file in your docs folder:
extensions = ["sphinxcontrib.runcmd"]
From there, all you need to do is use runcmd as a directive in your documentation files.
.. runcmd:: python script.py -h
:syntax: bash
:prompt:
Options
This directive is basically a sub-directive of code-block, so it has all of code blocks directives such as:
- linenos
- dedent
- lineno-start
- emphasize-lines
- caption
- class
- name
This directive builds upon that and adds the following:
- syntax: str
- Since we're using the arguments section for a command we can't actually pass the syntax we want to the
code-blockin the arguments. Therefore you can set it in the options which will then get passed into thecode-blockto colorize your commands output.
- Since we're using the arguments section for a command we can't actually pass the syntax we want to the
- replace: str
- Takes in a comma separated list of regex
pattern/replace,pattern/replaceand applies it to the output in that order.
- Takes in a comma separated list of regex
- prompt: bool
- Display the command prompt in the output
- dedent-output: int
- Will dedent the output only by the int value you specify. Will not dedent the prompt if specified. Be careful, because the
code-blockdedent will be applied on top of this dedent if both are set in the options.
- Will dedent the output only by the int value you specify. Will not dedent the prompt if specified. Be careful, because the
Replace Option
The replace option uses the CSV package to parse the string, thus you can wrap your replacements in double quotes if you want to use commas and whatnot.
You also need to double escape any forward slashes, but you can single escape quotes.
.. runcmd:: python test.py -h
:replace: "this\\/is\\/a\\/path/now\\/its\\/another\\/path","\"/'"
The first replacement will replace this/is/a/path with now/its/another/path.
The second replacement will replace " with '.
License
sphinxcontrib-runcmd is provided under an MIT License.
Project details
Release history Release notifications | RSS feed
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 sphinxcontrib-runcmd-0.2.0.tar.gz.
File metadata
- Download URL: sphinxcontrib-runcmd-0.2.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3551c389d9c5fe82d693c7222feb9658b1a1a5a1abcb0063e8385e5528c64c76
|
|
| MD5 |
f83279160447eb14ba9168f3283d2851
|
|
| BLAKE2b-256 |
a2036eb30814c9839f36131284a46ec9fc39d7bd356078648bc7125d5d1c05e8
|
File details
Details for the file sphinxcontrib_runcmd-0.2.0-py2.py3-none-any.whl.
File metadata
- Download URL: sphinxcontrib_runcmd-0.2.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b739b68e27210b4c7c12ba16e5b3da7b313c49991401f896d29bea0f0771934
|
|
| MD5 |
b5deff6afc851000d9b86d4f7bd4001a
|
|
| BLAKE2b-256 |
83d967a79080b5d9fcb367470af9e525a9c53122e95744665de09462dcd676d8
|