From b4895fb5fbbe4dd419257d68ad2d897d6b10863b Mon Sep 17 00:00:00 2001 From: Robpol86 Date: Fri, 2 Sep 2016 17:49:39 -0500 Subject: [PATCH] Handling overridden static path. --- sphinxcontrib/versioning/sphinx_.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sphinxcontrib/versioning/sphinx_.py b/sphinxcontrib/versioning/sphinx_.py index 833e6dca4..b9b34aad7 100644 --- a/sphinxcontrib/versioning/sphinx_.py +++ b/sphinxcontrib/versioning/sphinx_.py @@ -16,6 +16,7 @@ from sphinxcontrib.versioning.versions import Versions SC_VERSIONING_VERSIONS = list() # Updated after forking. +STATIC_DIR = os.path.join(os.path.dirname(__file__), '_static') class EventHandlers(object): @@ -114,9 +115,13 @@ def html_page_context(cls, app, pagename, templatename, context, doctree): if cls.SHOW_BANNER and 'body' in context: parsed = app.builder.templates.render('banner.html', context) context['body'] = parsed + context['body'] + # Handle overridden css_files. css_files = context.setdefault('css_files', list()) if '_static/banner.css' not in css_files: css_files.append('_static/banner.css') + # Handle overridden html_static_path. + if STATIC_DIR not in app.config.html_static_path: + app.config.html_static_path.append(STATIC_DIR) def setup(app): @@ -131,7 +136,7 @@ def setup(app): app.add_config_value('sphinxcontrib_versioning_versions', SC_VERSIONING_VERSIONS, 'html') # Needed for banner. - app.config.html_static_path.append(os.path.join(os.path.dirname(__file__), '_static')) + app.config.html_static_path.append(STATIC_DIR) app.add_stylesheet('banner.css') # Tell Sphinx which config values can be set by the user.