斯芬克斯文档项目的Documatt主题
sphinx-documatt-theme的Python项目详细描述
移动友好的斯芬克斯主题,旨在提供伟大的文件阅读体验与美丽的排版。在
这个主题是Documatt的Techwriter at work blog的默认主题,但是欢迎您将其用于任何Sphinx项目。在
安装
安装(在命令行上):
$ pip install sphinx-documatt-theme
使用它(在您的conf.py)中:
^{pr2}$配置
主题为唯一选项-设置“座右铭”默认显示在封面(靠近页眉的面包屑块下方)和页脚中。树立自己的座右铭:
html_theme_options = { "motto": "Write and read beautiful books and documentation in easy way with our powerful writing platform." }
定制
要自定义主题,请在Sphinx项目根目录中创建_templates/layout.html。layout.html是要重写的最重要的模板。以扩展名启动文件:
{% extends "!layout.html" %}
现在您可以覆盖(自定义)所谓的块,即页面的一部分。最重要的模块是:
- mastercover用于母版页的封面(有时称为英雄)(通常index.rst)。封面显示在面包屑导航下面。在
- nonmastercover用于非母版页的封面(通常是index.rst除外)的封面。默认情况下,两个封面块都显示座右铭。在
- coverrightcolumnright列位于封面旁边,例如对于社交按钮很有用。在
- rightsidebarright列,位于主文档正文旁边。同样,通常用于放置共享按钮。在
- extrafooter块在尾随</body>之前。默认情况下为空,但它是放置网站分析HTML代码或cookie bar的理想位置。在
完整的例子可能是:
{% extends "!layout.html" %} {% block mastercover %} <h1 class="title is-2 has-text-primary"> Techwriter at work <span class="has-text-weight-light">blog</span>. </h1> <h2 class="subtitle is-4"> Living and writing documentation at Documatt, small team of programmers that <span class="has-text-primary">do write</span> documentation too. </h2> {% endblock %} {% block coverrightcolumn %} <a href="https://twitter.com/documattcom?ref_src=twsrc%5Etfw" class="twitter-follow-button" data-show-count="false">Follow us</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> {% endblock %} {% block extrafooter %} <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cookie-bar/cookiebar-latest.min.js?theme=grey&tracking=1&thirdparty=1&always=1&hideDetailsBtn=1&showPolicyLink=1&privacyPage=https%3A%2F%2Fdocumatt.com%2Fabout%2Flegal%2Fprivacy%2F"></script> {% endblock %}
打开theme’s layout.html以查看可以重写的所有块。在
- 项目
标签: