Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG FIX] Enable alabaster render Travis CI badges for .com #147

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions alabaster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ def get_path():
def update_context(app, pagename, templatename, context, doctree):
context["alabaster_version"] = version.__version__

set_up_travis_context(context)


def set_up_travis_context(context):
"""Add complete Travis URLs to Jinja2 context."""
github_slug = "/".join(
(context["theme_github_user"], context["theme_github_repo"])
)

travis_button = str(context["theme_travis_button"]).lower()
travis_button_enabled = travis_button == "true"

travis_slug = github_slug if travis_button_enabled else travis_button

travis_tld = context["theme_travis_tld"].strip(".").lower()
travis_base_uri = "travis-ci.{}/{}".format(travis_tld, travis_slug)
context["theme_travis_build_url"] = "https://{}".format(travis_base_uri)
context["theme_travis_badge_url"] = "https://api.{}.svg?branch={}".format(
travis_base_uri, context["theme_badge_branch"]
)


def setup(app):
# add_html_theme is new in Sphinx 1.6+
Expand Down
11 changes: 3 additions & 8 deletions alabaster/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,11 @@ <h1 class="logo"><a href="{{ pathto(master_doc) }}">{{ project }}</a></h1>
{% endif %}

{% if theme_travis_button|lower != 'false' %}
{% if theme_travis_button|lower == 'true' %}
{% set path = theme_github_user + '/' + theme_github_repo %}
{% else %}
{% set path = theme_travis_button %}
{% endif %}
<p>
<a class="badge" href="https://travis-ci.org/{{ path }}">
<a class="badge" href="{{ theme_travis_build_url }}">
<img
alt="https://secure.travis-ci.org/{{ path }}.svg?branch={{ theme_badge_branch }}"
src="https://secure.travis-ci.org/{{ path }}.svg?branch={{ theme_badge_branch }}"
alt="Travis CI build badge"
src="{{ theme_travis_badge_url }}"
/>
</a>
</p>
Expand Down
1 change: 1 addition & 0 deletions alabaster/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sidebar_width = 220px
tidelift_url =
touch_icon =
travis_button = false
travis_tld = org

gray_1 = #444
gray_2 = #EEE
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Changelog
=========

- :release:`0.7.12 <2018-10-02>`
- :bug:`-` On some browsers/platforms, 'badge'-style sidebar elements were
displaying dotted underlines. This was unintentional and explicit styling has
been added to remove them. Credit to Steven Loria.
Expand Down
3 changes: 3 additions & 0 deletions docs/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ banners.
string - used to display a `Travis-CI <https://travis-ci.org>`_ build status
button in the sidebar. If ``true``, uses your ``github_(user|repo)``
settings.
* ``travis_tld``: ``com`` or ``org`` (default). If ``com``, the badge points
to the new `travis-ci.com <https://travis-ci.com>`_ platform, and points to
`travis-ci.org <https://travis-ci.org>`_ otherwise.

Non-service sidebar control
---------------------------
Expand Down