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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file sphinxcontrib-getthecode-0.1dev-20140921.tar.gz
.
File metadata
- Download URL: sphinxcontrib-getthecode-0.1dev-20140921.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef2495098b13aa699ea2273998a3e328e2650355781f3df29a1bc44c8429d46b |
|
MD5 | dec11bbe73f9e5dc9a86f850482d30e3 |
|
BLAKE2b-256 | f052a44c322431dc351860990ea3a82be009b38e0b283fd156578a777f303ded |