Skip to main content

Sphinx extension for OS code-blocks

Project description

Documentation Status

osexample extension for Sphinx

This is a modified fork of Serge Domkowski’s examplecode extension for Sphinx.


This is a simple extension that, when rendered as HTML, will fold multiple code blocks containing different operating systems administration examples into a single block which can be toggled from one to another using buttons.

It’s intended to be used for displaying package manager examples. (e.g., apt install or dnf install).

This extension adds the example-code directive which adds a class to a container wrapping the code blocks that should be folded. The class allows the included Javascript and CSS to render the folded block and buttons.

Currently supported are: Debian, Ubuntu, Fedora, CentOS, OSX

Quick Example

Source would look something like this:

.. example-code::
    .. code-block:: Debian

        sudo apt install htop

    .. code-block:: Fedora

        sudo dnf install htop

This will create an output like this:

Example how it looks like as generated HTML


$ pip install sphinxcontrib-osexample
Enabling the extension in Sphinx

Just add sphinxcontrib.examplecode to the list of extensions in the file. For example:

extensions = ['sphinxcontrib.osexample']


Full documentation for end users can be found in the “docs” folder.

It is also available online on Read The Docs



If you are having issues, please let us know.


The project is licensed under BSD.

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

sphinxcontrib-osexample-0.1.1.tar.gz (4.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page