Allow alternate OpenStack themes

By default oslosphinx forces projects that use it to use the theme
contained in the package. The documentation team wants to provide a
separate theme for some parts of the docs.openstack.org site. They are
going to distribute it in their own package, but do still want to be
able to use other features of oslosphinx. This change allows any name
that starts "openstack" to be used, while retaining the default behavior
of inserting the "openstack" theme if a project is using a different
default or has not set a theme.

Change-Id: I7a2c5a5c3805685b8fa0baaa47393d5fec312f30
This commit is contained in:
Doug Hellmann 2015-01-26 17:10:43 -05:00
parent f640b5e3f8
commit 7c282dc14a
1 changed files with 8 additions and 6 deletions

View File

@ -19,14 +19,16 @@ def builder_inited(app):
theme_dir = os.path.join(os.path.dirname(__file__), 'theme')
app.info('Using openstack 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. 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.
# 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
app.config.html_theme = 'openstack'
if not app.config.html_theme.startswith('openstack'):
app.config.html_theme = 'openstack'
# Re-initialize the builder, if it has the method for setting up
# the templates and theme.
if hasattr(app.builder, 'init_templates'):