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
Doug Hellmann
9 years ago
18 | 18 | theme_dir = os.path.join(os.path.dirname(__file__), 'theme') |
19 | 19 | app.info('Using openstack theme from %s' % theme_dir) |
20 | 20 | # Insert our theme directory at the front of the search path and |
21 | # force the theme setting to use the one in the package. This is | |
22 | # done here, instead of in setup(), because conf.py is read after | |
23 | # setup() runs, so if the conf contains these values the user | |
24 | # values overwrite these. That's not bad for the theme, but it | |
25 | # breaks the search path. | |
21 | # force the theme setting to use the one in the package unless | |
22 | # another openstack theme is already selected. This is done here, | |
23 | # instead of in setup(), because conf.py is read after setup() | |
24 | # runs, so if the conf contains these values the user values | |
25 | # overwrite these. That's not bad for the theme, but it breaks the | |
26 | # search path. | |
26 | 27 | app.config.html_theme_path.insert(0, theme_dir) |
27 | 28 | # Set the theme name |
28 | app.config.html_theme = 'openstack' | |
29 | if not app.config.html_theme.startswith('openstack'): | |
30 | app.config.html_theme = 'openstack' | |
29 | 31 | # Re-initialize the builder, if it has the method for setting up |
30 | 32 | # the templates and theme. |
31 | 33 | if hasattr(app.builder, 'init_templates'): |