狮身人面像扩展
sphinxcontrib-getthecode的Python项目详细描述
此插件为Sphinx文档生成器实现了增强的literalinclude指令。
对于演示,请查看Pyterate。
作者是Fabrice Salvaire。
源代码托管在https://github.com/FabriceSalvaire/sphinx-getthecode
安装
使用pip:
pip install sphinxcontrib-getthecode
否则克隆git存储库:
git clone git@github.com:FabriceSalvaire/sphinx-getthecode
然后使用:
python setup.py install
用法
要加载插件,必须将其添加到conf.py文件中。
extensions=[...'sphinxcontrib.getthecode',]
指令
这个插件实现了一个指令getthecode,它相当于literalinclude 指令,但它在pre元素之前添加了一个头。此头包含文件名和 下载文件的链接。
..getthecode:: example.py :language:python3:hidden:### optional, add a class highlight-hidden
将导致:
<divclass="getthecode"><divclass="getthecode-header"><ul><liclass="getthecode-filename">example.py</li><liclass="getthecode-filename-link"><ahref="../../_downloads/example.py"><span>example.py</span><iclass="fa fa-download"aria-hidden="true"></i></a></li><liclass="show-code-button"title="Show/Hide the code"><iclass="fa fa-eye"aria-hidden="true"></i><iclass="fa fa-eye-slash"aria-hidden="true"style="display: none;"></i></li></ul></div><divclass="highlight-python3 highlight-hidden"style="display: none;"><divclass="highlight"><pre> ... </pre></div></div></div>
您可以在static目录中找到css样式表和javascript代码的示例,以显示/隐藏代码。