@@ -155,6 +155,8 @@ def get_github_data(project_urls):
155155 'github_repo' : PRJ_GITHUB_REPO ,
156156 'github_type' : 'star' ,
157157 'github_banner' : True ,
158+ 'travis_button' : True ,
159+ # 'travis_tld': 'com',
158160 'show_relbars' : True ,
159161 'show_related' : True ,
160162 'extra_nav_links' : {
@@ -275,3 +277,34 @@ def get_github_data(project_urls):
275277
276278# If true, `todo` and `todoList` produce output, else they produce nothing.
277279todo_include_todos = True
280+
281+
282+ # Patch alabaster theme
283+ # Ref: https://github.com/bitprophet/alabaster/pull/147
284+ # FIXME: drop this hack once the PR is merged & released; pylint: disable=fixme
285+ def set_up_travis_context (
286+ app , pagename , templatename , # pylint: disable=unused-argument
287+ context ,
288+ doctree , # pylint: disable=unused-argument
289+ ):
290+ """Add complete Travis URLs to Jinja2 context."""
291+ github_slug = '/' .join (
292+ (context ['theme_github_user' ], context ['theme_github_repo' ]),
293+ )
294+
295+ travis_button = str (context ['theme_travis_button' ]).lower ()
296+ travis_button_enabled = travis_button == 'true'
297+
298+ travis_slug = github_slug if travis_button_enabled else travis_button
299+
300+ travis_tld = 'com' # context["theme_travis_tld"].strip(".").lower()
301+ travis_base_uri = 'travis-ci.{}/{}' .format (travis_tld , travis_slug )
302+ context ['theme_travis_build_url' ] = 'https://{}' .format (travis_base_uri )
303+ context ['theme_travis_badge_url' ] = 'https://api.{}.svg?branch={}' .format (
304+ travis_base_uri , context ['theme_badge_branch' ],
305+ )
306+
307+
308+ def setup (app ):
309+ """Patch the sphinx theme set up stage."""
310+ app .connect ('html-page-context' , set_up_travis_context )
0 commit comments