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

Support generic badges #124

Open
wants to merge 1 commit 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/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,24 @@ <h1 class="logo"><a href="{{ pathto(master_doc) }}">{{ project }}</a></h1>
</a>
</p>
{% endif %}

{% if theme_badges %}
{% for badge in theme_badges %}
<p>
<a href="{{ badge['target'] }}">
<img
src="{{ badge['image'] }}"
{% if 'alt' in badge %}
alt="{{ badge['alt'] }}"
{% endif %}
{% if 'width' in badge %}
width="{{ badge['width'] }}"
{% endif %}
{% if 'height' in badge %}
height="{{ badge['height'] }}"
{% endif %}
/>
</a>
</p>
{% endfor %}
{% endif %}
1 change: 1 addition & 0 deletions alabaster/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ github_count = true
badge_branch = master
travis_button = false
codecov_button = false
badges =
gratipay_user =
gittip_user =
analytics_id =
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Changelog
=========

* :feature:`120` Support generic badges by ``badges`` config
option. Credit: Andrew Svetlov.
* :support:`- backported` Miscellaneous project maintenance updates such as
adding to Travis CI and enforcing the use of ``flake8``.
* :feature:`110 backported` Add ``badge_branch`` option allowing
Expand Down
29 changes: 27 additions & 2 deletions docs/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Alabaster's behavior & style can be customized in multiple ways:
.. note::
Some theme options implemented prior to 0.7.8 would have been more suitable
as local custom stylesheet overrides. Therefore:

* We no longer accept feature requests which are more appropriately solved
by using this functionality instead.
* In future backwards-incompatible versions we may deprecate some of those
options; as such we highly recommend leveraging the custom stylesheet
whenever possible, even if an option is present below.

* When in doubt, simply check `the built-in stylesheet's template
<https://github.com/bitprophet/alabaster/blob/master/alabaster/static/alabaster.css_t>`_
to see whether the option you're looking at is a basic variable
Expand Down Expand Up @@ -115,6 +115,31 @@ Variables and feature toggles
string - used to display a `Codecov <https://codecov.io>`_ build status
button in the sidebar. If ``true``, uses your ``github_(user|repo)``
settings; defaults to ``false.``
* ``badges``: A list of dictionaries to add a custom badges. Every
dict is a badge description with the following keys:

* *image*: badge's image URI
* *target*: destination link for badge, a target for
clicking on image.
* *alt* (optional): alternate text: a short description of the image,
displayed by applications that cannot display images, or spoken by
applications for visually impaired users.
* *width* (optional): the width of image
* *height* (optional): the height of image

Example::

html_theme_options = {
...
'badges': [{'image': 'https://badge.fury.io/py/aiohttp.svg',
'target': 'https://badge.fury.io/py/aiohttp',
'alt': 'Latest PyPI package version'},
{'image': 'https://badges.gitter.im/Join%20Chat.svg',
'target': 'https://gitter.im/aio-libs/Lobby',
'alt': 'Chat on Gitter'}],
...
}

* ``gratipay_user``: Set to your `Gratipay <https://gratipay.com>`_ username
if you want a Gratipay 'Donate' section in your sidebar.

Expand Down