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 https://github.com/FabriceSalvaire/sphinx-getthecode
Installation
Using pip:
pip install sphinxcontrib-getthecode
Else clone the Git repository:
git clone git@github.com:FabriceSalvaire/sphinx-getthecode
then install the plugin using:
python setup.py install
Usage
To load the plugin, you have to add it in your conf.py file.
extensions = [
...
'sphinxcontrib.getthecode',
]
Directives
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:: example.py
:language: python3
:hidden: ### optional, add a class highlight-hidden
will result in:
<div class="getthecode">
<div class="getthecode-header">
<ul>
<li class="getthecode-filename">example.py</li>
<li class="getthecode-filename-link">
<a href="../../_downloads/example.py">
<span>example.py</span>
<i class="fa fa-download" aria-hidden="true"></i>
</a></li>
<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>
</li></ul>
</div>
<div class="highlight-python3 highlight-hidden" style="display: none;">
<div class="highlight">
<pre>
...
</pre>
</div>
</div>
</div>
You can find in the static directory an example of CSS stylesheet and a Javascript code to show/hide the code.
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
Built Distribution
Hashes for sphinxcontrib-getthecode-1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | edddfca103b8b7422579ba17c3a60b31bc2919d36b642bdef894d3789f9f7c03 |
|
MD5 | 799d981b46fff4ec7ecc59ae6d4b2fdf |
|
BLAKE2b-256 | 0af0c2fa9707f7cc3843c24137232c16086a7999324fb51aff7d9a729b37497f |
Hashes for sphinxcontrib_getthecode-1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc9d70aa6325d60cacb11d94085068230ed82567d2212ba5d692facb55f74cb5 |
|
MD5 | ed235b56f74c1d3f00a1b78b8f026f9c |
|
BLAKE2b-256 | c5331802982f27785e3276ef15de4b9fba72bbbf574882f3e7ec243ac57b2701 |