Skip to content

Commit

Permalink
Handling overridden static path.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robpol86 committed Sep 2, 2016
1 parent 10188d8 commit b4895fb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sphinxcontrib/versioning/sphinx_.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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.
Expand Down

0 comments on commit b4895fb

Please sign in to comment.