https://github.com/fabricesalvaire/sphinx-getthecode
This plugin provides an enhanced literalinclude directive for the Sphinx Documentation Generator.
https://github.com/fabricesalvaire/sphinx-getthecode
sphinx-plugin
Last synced: 16 days ago
JSON representation
This plugin provides an enhanced literalinclude directive for the Sphinx Documentation Generator.
- Host: GitHub
- URL: https://github.com/fabricesalvaire/sphinx-getthecode
- Owner: FabriceSalvaire
- License: gpl-3.0
- Created: 2014-09-08T09:37:54.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2020-05-18T19:57:50.000Z (about 6 years ago)
- Last Synced: 2024-05-19T00:05:40.756Z (about 2 years ago)
- Topics: sphinx-plugin
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
.. |Pypi Version| image:: https://img.shields.io/pypi/v/sphinxcontrib-getthecode.svg
:target: https://pypi.python.org/pypi/sphinxcontrib-getthecode
:alt: sphinxcontrib-getthecode last version
.. |Pypi License| image:: https://img.shields.io/pypi/l/sphinxcontrib-getthecode.svg
:target: https://pypi.python.org/pypi/sphinxcontrib-getthecode
:alt: sphinxcontrib-getthecode license
.. |Pypi Python Version| image:: https://img.shields.io/pypi/pyversions/sphinxcontrib-getthecode.svg
:target: https://pypi.python.org/pypi/sphinxcontrib-getthecode
:alt: sphinxcontrib-getthecode python version
.. |Python| replace:: Python
.. _Python: http://python.org
.. |PyPI| replace:: PyPI
.. _PyPI: https://pypi.python.org/pypi
.. |Sphinx| replace:: Sphinx
.. _Sphinx: http://sphinx-doc.org
==============================
GetTheCode plugin for Sphinx
==============================
|Pypi License|
|Pypi Python Version|
|Pypi Version|
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``:
.. code-block:: bash
pip install sphinxcontrib-getthecode
Else clone the Git repository:
.. code-block:: sh
git clone git@github.com:FabriceSalvaire/sphinx-getthecode
then install the plugin using:
.. code-block:: bash
python setup.py install
Usage
-----
To load the plugin, you have to add it in your ``conf.py`` file.
.. code-block:: python
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.
.. code-block:: ReST
.. getthecode:: example.py
:language: python3
:hidden: ### optional, add a class highlight-hidden
:notebook: ### optional, if a example.ipynb is available
will result in:
.. code-block:: html
You can find in the ``static`` directory an example of **CSS stylesheet** and a **Javascript code to show/hide the code**.
You can customise the HTML code using the ``getthecode_header_template`` configuration variable that
contains a Jinja2 template, by default set to:
.. code:: html