Skip to main content

Material sphinx theme

Project description

Continuous Integration

Travis Build Status

A Material Design theme for Sphinx documentation. Based on Material for MkDocs, and Guzzle Sphinx Theme.

Installation

Install via pip:

$ pip install git+https://github.com/bashtage/sphinx-material

or if you have the code checked out locally:

$ python setup.py install

Configuration

Add the following to your conf.py:

import sphinx_material

 # Register the theme as an extension to generate a sitemap.xml
extensions.append('sphinx_material')

# Choose the material theme
html_theme = 'sphinx_material'
# Get the them path
html_theme_path = sphinx_material.html_theme_path()
# Register the required helpers for the html context
html_context = sphinx_material.get_html_context()

There are a lot more ways to customize this theme, as this more comprehensive example shows:

import sphinx_material

# Required theme setup
extensions.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,
}

Customizing the layout

You can customize the theme by overriding Jinja template blocks. For example, ‘layout.html’ contains several blocks that can be overridden or extended.

Place a ‘layout.html’ file in your project’s ‘/_templates’ directory.

mkdir source/_templates
touch source/_templates/layout.html

Then, configure your ‘conf.py’:

templates_path = ['_templates']

Finally, edit your override file ‘source/_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 %}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

sphinx_material-0.0.3-py3-none-any.whl (503.9 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_material-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: sphinx_material-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 503.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4

File hashes

Hashes for sphinx_material-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0fc5caa3b1f36af6a37cb7aeceb99c055e73af602c7e281bd3698c5c91c6e53
MD5 2f052d1d01db973fc56d0d6217a2b213
BLAKE2b-256 7c51b4c999f863ae6b31219e22493346c7d4de01424561b74506a661ac408ff4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page