Skip to main content

Sphinx "getthecode" extension

Project description

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

Written by Fabrice Salvaire.

Installation

See sphinx-contrib for more details.

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

python setup.py build
python setup.py install

The PySpice source code is hosted at https://github.com/FabriceSalvaire/sphinx-getthecode

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

git clone git@github.com:FabriceSalvaire/sphinx-getthecode

Usage

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

extensions = [
  ...
  'sphinxcontrib.getthecode',
  ]

Directives

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:: example.py
  :language: python

will result in:

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

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