Skip to main content

Provides a sphinx code-block for rendering RunThis blocks

Project description

runthis-sphinxext

This provides a sphinx extension that adds RunThis code blocks, which display a highligthed code-block statically, but with a "RunThis" button above them. When the button is clicked, the code block is replaced by a terminal session that has executed that code.

Installation

RunThis Sphinx Extention may be installed with either conda or pip:

# use the conda-forge channel
$ conda install -c conda-forge runthis-sphinxext

# Or you can use Pip, if you must.
$ pip install runthis-sphinxext

Configuration

To use the RunThis code blocks, you must configure sphinx to know about RunThis. First, make sure the sphinx extension is registered. In the conf.py, add runthis.sphinxext somewhere in the extensions block:

extensions = [
    ...
    "runthis.sphinxext",
    ...
]

After this, you also need to tell sphinx where the RunThis Server is located. This can be set with the runthis_server variable anywhere in the conf.py. For example:

# runthis options
runthis_server = "http://localhost:5000"

Usage

To use the RunThis directive is very similar to the code-block directive in rST. In any of your *.rst files, you may use the runthis directive, followed by the language name on the same line. After any code-block options and one or more blank lines, the code that you wish to display and run, is in an indented block. For example:

.. runthis:: python

    import sys
    print(sys.executable)

This will be run on the remote server specified in the conf.py file.

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

runthis-sphinxext-0.0.2.tar.gz (15.2 kB view details)

Uploaded Source

File details

Details for the file runthis-sphinxext-0.0.2.tar.gz.

File metadata

  • Download URL: runthis-sphinxext-0.0.2.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0.post20200311 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

File hashes

Hashes for runthis-sphinxext-0.0.2.tar.gz
Algorithm Hash digest
SHA256 d7fe049d153d71c2b796e64b125de2870ffe09f016cc66fa8bbaed0d2f205ec2
MD5 dc1dff65c446548d3b97ad4adeba344f
BLAKE2b-256 281546fa11cbd64f285096859eb6fb7f367dbed52b20ad2a56fe42d9609deb09

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page