Don't force-inject the theme

Let the user configure their project to use the theme, and don't
automatically assume they want to use our theme just because the package
is present. This allows this theme to live with oslosphinx, which forces
the theme setting.
This commit is contained in:
Doug Hellmann 2015-01-28 16:49:22 -05:00
parent 3c903688db
commit 49fda78a27
2 changed files with 10 additions and 25 deletions

View File

@ -15,6 +15,8 @@
import sys
import os
import openstackdocstheme
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
@ -28,7 +30,7 @@ import os
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['openstackdocstheme']
extensions = []
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
@ -98,7 +100,7 @@ pygments_style = 'sphinx'
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
html_theme = 'openstackdocs'
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
@ -106,7 +108,7 @@ html_theme = 'default'
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
html_theme_path = [openstackdocstheme.get_html_theme_path()]
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".

View File

@ -15,25 +15,8 @@
import os
def builder_inited(app):
theme_dir = os.path.join(os.path.dirname(__file__), 'theme')
app.info('Using openstackdocs theme from %s' % theme_dir)
# Insert our theme directory at the front of the search path and
# force the theme setting to use the one in the package unless
# another openstack theme is already selected. This is done here,
# instead of in setup(), because conf.py is read after setup()
# runs, so if the conf contains these values the user values
# overwrite these. That's not bad for the theme, but it breaks the
# search path.
app.config.html_theme_path.insert(0, theme_dir)
# Set the theme name
if not app.config.html_theme.startswith('openstack'):
app.config.html_theme = 'openstackdocs'
# Re-initialize the builder, if it has the method for setting up
# the templates and theme.
if hasattr(app.builder, 'init_templates'):
app.builder.init_templates()
def setup(app):
app.connect('builder-inited', builder_inited)
def get_html_theme_path():
"""Return the directory containing our HTML theme."""
cur_dir = os.path.abspath(os.path.dirname(__file__))
d = os.path.join(cur_dir, 'theme')
return d