{"id":16484387,"url":"https://github.com/fabricesalvaire/sphinx-getthecode","last_synced_at":"2026-06-10T19:31:58.740Z","repository":{"id":20506954,"uuid":"23785528","full_name":"FabriceSalvaire/sphinx-getthecode","owner":"FabriceSalvaire","description":"This plugin provides an enhanced literalinclude directive for the Sphinx Documentation Generator.","archived":false,"fork":false,"pushed_at":"2020-05-18T19:57:50.000Z","size":41,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-19T00:05:40.756Z","etag":null,"topics":["sphinx-plugin"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FabriceSalvaire.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-08T09:37:54.000Z","updated_at":"2023-09-26T08:50:23.000Z","dependencies_parsed_at":"2022-09-09T12:01:31.765Z","dependency_job_id":null,"html_url":"https://github.com/FabriceSalvaire/sphinx-getthecode","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabriceSalvaire%2Fsphinx-getthecode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabriceSalvaire%2Fsphinx-getthecode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabriceSalvaire%2Fsphinx-getthecode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FabriceSalvaire%2Fsphinx-getthecode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FabriceSalvaire","download_url":"https://codeload.github.com/FabriceSalvaire/sphinx-getthecode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241241071,"owners_count":19932679,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sphinx-plugin"],"created_at":"2024-10-11T13:16:57.934Z","updated_at":"2026-06-10T19:31:58.733Z","avatar_url":"https://github.com/FabriceSalvaire.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. |Pypi Version| image:: https://img.shields.io/pypi/v/sphinxcontrib-getthecode.svg\n   :target: https://pypi.python.org/pypi/sphinxcontrib-getthecode\n   :alt: sphinxcontrib-getthecode last version\n\n.. |Pypi License| image:: https://img.shields.io/pypi/l/sphinxcontrib-getthecode.svg\n   :target: https://pypi.python.org/pypi/sphinxcontrib-getthecode\n   :alt: sphinxcontrib-getthecode license\n\n.. |Pypi Python Version| image:: https://img.shields.io/pypi/pyversions/sphinxcontrib-getthecode.svg\n   :target: https://pypi.python.org/pypi/sphinxcontrib-getthecode\n   :alt: sphinxcontrib-getthecode python version\n\n.. |Python| replace:: Python\n.. _Python: http://python.org\n\n.. |PyPI| replace:: PyPI\n.. _PyPI: https://pypi.python.org/pypi\n\n.. |Sphinx| replace:: Sphinx\n.. _Sphinx: http://sphinx-doc.org\n\n==============================\n GetTheCode plugin for Sphinx\n==============================\n\n|Pypi License|\n|Pypi Python Version|\n\n|Pypi Version|\n\nThis plugin implements an enhanced ``literalinclude`` directive for the `Sphinx`_ Documentation Generator.\n\nFor a demo, look at `Pyterate \u003chttps://github.com/FabriceSalvaire/Pyterate\u003e`_.\n\nAuthored by `Fabrice Salvaire \u003chttp://fabrice-salvaire.fr\u003e`_.\n\nSource code is hosted at https://github.com/FabriceSalvaire/sphinx-getthecode\n\nInstallation\n------------\n\nUsing ``pip``:\n\n.. code-block:: bash\n\n    pip install sphinxcontrib-getthecode\n\nElse clone the Git repository:\n\n.. code-block:: sh\n\n  git clone git@github.com:FabriceSalvaire/sphinx-getthecode\n\nthen install the plugin using:\n\n.. code-block:: bash\n\n    python setup.py install\n\nUsage\n-----\n\nTo load the plugin, you have to add it in your ``conf.py`` file.\n\n.. code-block:: python\n\n    extensions = [\n      ...\n      'sphinxcontrib.getthecode',\n      ]\n\nDirectives\n----------\n\nThis plugin implements a directive ``getthecode`` which is equivalent to the ``literalinclude``\ndirective, but it adds a header before the ``pre`` element.  This header contains the file name and\na link to download the file.\n\n.. code-block:: ReST\n\n    .. getthecode:: example.py\n        :language: python3\n        :hidden: ### optional, add a class highlight-hidden\n\t:notebook: ### optional, if a example.ipynb is available\n\nwill result in:\n\n.. code-block:: html\n\n    \u003cdiv class=\"getthecode\"\u003e\n        \u003cdiv class=\"getthecode-header\"\u003e\n            \u003cul\u003e\n                \u003cli class=\"getthecode-filename\"\u003eexample.py\u003c/li\u003e\n\n                \u003cli class=\"getthecode-filename-link\"\u003e\n                    \u003ca href=\"../example.py\" download=\"example.py\" type=\"text/x-python\" target=\"_blank\" rel=\"noreferrer noopener\"\u003e\n                        \u003cspan\u003e example.py \u003c/span\u003e\n                    \u003c/a\u003e\n                \u003c/li\u003e\n\n                \u003cli class=\"getthecode-notebook-link\"\u003e\n                    \u003ca href=\"../example.ipynb\" download=\"example.ipynb\" type=\"application/x-ipynb+json\" target=\"_blank\" rel=\"noreferrer noopener\"\u003e\n                        \u003cspan\u003e example.ipynb \u003c/span\u003e\n                    \u003c/a\u003e\n                \u003c/li\u003e\n\n                \u003c!-- Added by javascript --\u003e\n                \u003cli class=\"show-code-button\" title=\"Show/Hide the code\"\u003e\n                    \u003ci class=\"fa fa-eye\" aria-hidden=\"true\"\u003e\u003c/i\u003e\n                    \u003ci class=\"fa fa-eye-slash\" aria-hidden=\"true\" style=\"display: none;\"\u003e\u003c/i\u003e\n                \u003c/li\u003e\n            \u003c/ul\u003e\n        \u003c/div\u003e\n\n        \u003cdiv class=\"highlight-python3 highlight-hidden\" style=\"display: none;\"\u003e\n            \u003cdiv class=\"highlight\"\u003e\n                \u003cpre\u003e \u003c/pre\u003e\n            \u003c/div\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\nYou can find in the ``static`` directory an example of **CSS stylesheet** and a **Javascript code to show/hide the code**.\n\nYou can customise the HTML code using the ``getthecode_header_template`` configuration variable that\ncontains a Jinja2 template, by default set to:\n\n.. code:: html\n\n    \u003cdiv class=\"getthecode-header\"\u003e\n      \u003cul\u003e\n        \u003cli class=\"getthecode-filename\"\u003e{{ filename }}\u003c/li\u003e\n        \u003cli class=\"getthecode-filename-link\"\u003e\n          \u003ca href=\"{{ url }}\" download={{ filename }} type=\"text/x-python\" target=\"_blank\" rel=\"noreferrer noopener\"\u003e\u003cspan\u003e\n            {{ filename }}\n          \u003c/span\u003e\u003c/a\u003e\n        \u003c/li\u003e\n    {% if notebook_url %}\n        \u003cli class=\"getthecode-notebook-link\"\u003e\n          \u003ca href=\"{{ notebook_url }}\" download={{ notebook_filename }} type=\"application/x-ipynb+json\" target=\"_blank\" rel=\"noreferrer noopener\"\u003e\u003cspan\u003e\n            {{ notebook_filename }}\n          \u003c/span\u003e\u003c/a\u003e\n        \u003c/li\u003e\n    {% endif %}\n      \u003c/ul\u003e\n    \u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabricesalvaire%2Fsphinx-getthecode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabricesalvaire%2Fsphinx-getthecode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabricesalvaire%2Fsphinx-getthecode/lists"}