材质狮身人面像主题
sphinx-material的Python项目详细描述
连续集成
发布
许可证
狮身人面像文件的材料设计主题。基于 Material for MkDocs, 以及Guzzle Sphinx Theme。
查看主题的demonstration site 例如渲染的rst。
安装
通过PIP安装:
$ pip install git+https://github.com/bashtage/sphinx-material
或者如果您已在本地签出代码:
$ python setup.py install
配置
在conf.py中添加以下内容:
importsphinx_material# Register the theme as an extension to generate a sitemap.xmlextensions.append('sphinx_material')# Choose the material themehtml_theme='sphinx_material'# Get the them pathhtml_theme_path=sphinx_material.html_theme_path()# Register the required helpers for the html contexthtml_context=sphinx_material.get_html_context()
有很多方法可以定制这个主题,因为它更加全面 示例显示:
importsphinx_material# Required theme setupextensions.append('sphinx_material')html_theme='sphinx_material'html_theme_path=sphinx_material.html_theme_path()html_context=sphinx_material.get_html_context()# Material theme options (see theme.conf for more information)html_theme_options={# Set the name of the project to appear in the navigation.'nav_name':'Project Name',# Set you GA account ID to enable tracking'google_analytics_account':'UA-XXXXX',# Specify a base_url used to generate sitemap.xml. If not# specified, then no sitemap will be built.'base_url':'https://project.github.io/project',# Set the color and the accent color'color_primary':'blue','color_accent':'light-blue'# Set the repo location to get a badge with stats'repo_url':'https://github.com/project/project/','repo_name':'Project',# 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 %}