Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Sphinx getthecode extension

Project Description

This plugin implements an enhanced literalinclude directive for the Sphinx Documentation Generator.

For a demo, look at Pyterate.

Authored by Fabrice Salvaire.

Source code is hosted at


Using pip:

pip install sphinxcontrib-getthecode

Else clone the Git repository:

git clone

then install the plugin using:

python install


To load the plugin, you have to add it in your file.

extensions = [


This plugin implements a directive getthecode which is equivalent to the literalinclude directive, but it adds a header before the pre element. This header contains the file name and a link to download the file.

.. getthecode::
    :language: python3
    :hidden: ### optional, add a class highlight-hidden

will result in:

<div class="getthecode">
    <div class="getthecode-header">
        <li class="getthecode-filename"></li>
        <li class="getthecode-filename-link">
            <a href="../../_downloads/">
                <i class="fa fa-download" aria-hidden="true"></i>
        <li class="show-code-button" title="Show/Hide the code">
            <i class="fa fa-eye" aria-hidden="true"></i>
            <i class="fa fa-eye-slash" aria-hidden="true" style="display: none;"></i>
    <div class="highlight-python3 highlight-hidden" style="display: none;">
    <div class="highlight">

You can find in the static directory an example of CSS stylesheet and a Javascript code to show/hide the code.

Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
sphinxcontrib_getthecode-1.0.0-py2.py3-none-any.whl (8.0 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Nov 26, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting