Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,16 @@ Add the following to your conf.py:

.. code-block:: python

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:

.. code-block:: python

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 = {
Expand Down
16 changes: 0 additions & 16 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,31 +43,15 @@ Update your ``conf.py`` with the required changes:

.. code-block:: python

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. See :ref:`Customization`
or ``theme.conf`` for more details.

.. code-block:: python

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 = {
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
],
entry_points={
'sphinx.html_themes': [
'sphinx_material = sphinx_material',
]
},
)
9 changes: 9 additions & 0 deletions sphinx_material/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ def setup(app):
app.connect("build-finished", create_sitemap)
app.connect("build-finished", reformat_pages)
app.connect("build-finished", minify_css)
app.connect("builder-inited", update_html_context)
manager = Manager()
site_pages = manager.list()
sitemap_links = manager.list()
app.multiprocess_manager = manager
app.sitemap_links = sitemap_links
app.site_pages = site_pages
app.add_html_theme(
'sphinx_material',
os.path.join(html_theme_path()[0], 'sphinx_material'))
return {
"version": __version__,
"parallel_read_safe": True,
Expand Down Expand Up @@ -133,6 +137,11 @@ def minify_css(app, exception):
app.multiprocess_manager.shutdown()


def update_html_context(app):
config = app.config
config.html_context = {**get_html_context(), **config.html_context}


def html_theme_path():
return [os.path.dirname(os.path.abspath(__file__))]

Expand Down