梅茜用的狮身人面像
Maisie-Sphinx-Theme的Python项目详细描述
梅西使用的狮身人面像主题:https://docs.maisie.dev
基于guzzle主题:http://guzzlephp.org
安装
通过PIP安装:
$ pip install Maisie-Sphinx-Theme
或者如果您已在本地签出代码:
$ python setup.py install
配置
在conf.py中添加以下内容:
importmaisie_sphinx_themehtml_theme_path=maisie_sphinx_theme.html_theme_path()html_theme='maisie_sphinx_theme'# Register the theme as an extension to generate a sitemap.xmlextensions.append("maisie_sphinx_theme")# Maisie theme options (see theme.conf for more information)html_theme_options={# Set the name of the project to appear in the sidebar"project_nav_name":"Project Name",}
有很多方法可以定制这个主题,因为它更加全面 示例显示:
importmaisie_sphinx_themehtml_theme_path=maisie_sphinx_theme.html_theme_path()html_theme='maisie_sphinx_theme'# Register the theme as an extension to generate a sitemap.xmlextensions.append("maisie_sphinx_theme")# Maisie theme options (see theme.conf for more information)html_theme_options={# Set the path to a special layout to include for the homepage"index_template":"special_index.html",# Set the name of the project to appear in the left sidebar."project_nav_name":"Project Name",# Set your Disqus short name to enable comments"disqus_comments_shortname":"my_disqus_comments_short_name",# Set you GA account ID to enable tracking"google_analytics_account":"my_ga_account",# Path to a touch icon"touch_icon":"",# Specify a base_url used to generate sitemap.xml links. If not# specified, then no sitemap will be built."base_url":"",# Allow a separate homepage from the master_doc"homepage":"index",# Allow the project link to be overriden to a custom URL."projectlink":"http://myproject.url",# Visible levels of the global TOC; -1 means unlimited"globaltoc_depth":3,# If False, expand all TOC entries"globaltoc_collapse":False,# If True, show hidden TOC entries"globaltoc_includehidden":False,}
自定义布局
可以通过重写jinja模板块自定义主题。例如, “layout.html”包含几个可以重写或扩展的块。
将“layout.html”文件放在项目的“/\u templates”目录中。
mkdir source/_templates touch source/_templates/layout.html
然后,配置“conf.py”:
templates_path=['_templates']
最后,编辑覆盖文件“source/\u templates/layout.html”:
{# Import the theme's layout. #} {% extends "!layout.html" %} {%- block extrahead %} {# Add custom things to the head HTML tag #} {# Call the parent block #} {{ super() }} {%- endblock %}
注意
如果您使用的是readthedocs,那么您可能会遇到一个问题,即 当前不允许扩展layout.html。