Skip to main content
https://github.com/tillahoffmann/sphinxcontrib-shtest/actions/workflows/main.yaml/badge.svg https://img.shields.io/pypi/v/sphinxcontrib-shtest

shtest tests shell commands in your Sphinx documentation. The shtest directive supports the usual doctest syntax. It offers the following options:

  • :returncode: [integer] specifies the expected return code (defaults to 0).

  • adding the :stderr: flag compares results with the stderr rather than stdout stream.

  • :cwd: [relative path] specifies the working directory relative to the source of the document (defaults to the directory containing the source document).

  • :tempdir: executes the test in a temporary directory.

Examples

# Obligatory hello world example.
$ echo hello world
hello world
:stderr:

# Read from stderr instead of stdout.
$ echo message on stderr >&2
message on stderr
:returncode: 1

# Use a non-zero expected return code.
$ false
# Run multiple tests in one directive.
$ echo hello
hello
$ echo world
world
:cwd: tests

# Run a test in a particular working directory relative to the document.
$ cat hello.txt
world
:tempdir:

# Run a test in a temporary directory.
$ echo hello > world.txt

Installation

Run pip install sphinxcontrib-shtest to install the package and add "sphinxcontrib.shtest" to your extensions list in conf.py (see here for details). Then execute sphinx-build -b shtest /path/to/source/directory /path/to/output/directory.

Metadata

Release files for sphinxcontrib-shtest 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinxcontrib-shtest 0.5.0
File Size Uploaded
sphinxcontrib-shtest-0.5.0.tar.gz 5.3 kB Details

Release files / sphinxcontrib-shtest-0.5.0.tar.gz

Download URL sphinxcontrib-shtest-0.5.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
65753c0ae0869ccfac53218cb491a253cd3965e730b74496c65c8938975cfafc
BLAKE2b-256 checksum
How to use checksums
c0f06a4deed6434d9fc80ed33069b51895cfb9ac1eb2d3f578493beb3645360f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.5.0 This release

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page