Skip to main content

Sphinx "getthecode" extension

Project description

This plugin provides an enhanced literalinclude directive for Sphinx Documentation Generator.

Written by Fabrice Salvaire.


See sphinx-contrib for more details.

To install the plugin, you have to run these commands:

python build
python install

The PySpice source code is hosted at

To clone the Git repository, run this command in a terminal:

git clone


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

extensions = [


This plugin adds a new directive getthecode which is equivalent to the literalinclude directive, but adds in front of the code block an header with the file name and an icon to download the file.

.. getthecode::
  :language: python

will result in:

<div class="getthecode">
  <div class="getthecode-header">
    <span class="getthecode-filename"></span>
    <a href="../../../_downloads/"><span></span></a>
  <div class="highlight-python">
    <div class="highlight"><pre>

To work properly, you must add some definitions in your CSS style, for example:

div.getthecode {
  border-radius: 3px;

div.getthecode-header {
  padding: 5px;
  margin-bottom: 0px;
  border-bottom: 1px solid rgb(216, 216, 216);
  background-repeat: repeat-x;
  background-color: rgb(234, 234, 234);
  background-image: linear-gradient(rgb(250, 250, 250), rgb(234, 234, 234));

div.getthecode-header span {

div.getthecode-header a {
  margin-left: .5em;
  display: inline-block;
  background-image: url("file-text-small.png");
  background-repeat: no-repeat;
  width: 16px;
  height: 16px;
  /* text-indent :-9999px; */ /* hide text */

div.getthecode-header a span {
  display: none;

div.getthecode pre {
  margin-top: 0px;
  padding: 3px;

Project details

Download files

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

Files for sphinxcontrib-getthecode, version 0.1dev-20140921
Filename, size File type Python version Upload date Hashes
Filename, size sphinxcontrib-getthecode-0.1dev-20140921.tar.gz (7.8 kB) File type Source Python version None Upload date Hashes View

Supported by

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