-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding CLI options, Sphinx context variables, etc for displaying banner messages on non-latest versions. Fixes #13
- Loading branch information
Showing
23 changed files
with
541 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.. _banner: | ||
|
||
============== | ||
Banner Message | ||
============== | ||
|
||
Banner messages can be displayed at the top of every document informing users that they are currently viewing either old | ||
or the development version of the project's documentation, with the exception of the :option:`--banner-main-ref`. This | ||
feature is inspired by banner on the `Jinja2 documentation <http://jinja.pocoo.org/docs/dev/>`_. | ||
|
||
The banner feature is disabled by default. It can be enabled with the :option:`--show-banner` setting. | ||
|
||
.. figure:: screenshots/sphinx_rtd_theme_banner_dev.png | ||
:target: _images/sphinx_rtd_theme_banner_dev.png | ||
|
||
The message displayed when users are viewing docs from a branch and the :option:`--banner-main-ref` is a tag. The | ||
entire banner is a link that sends users to the latest version of the current page if it exists there. | ||
|
||
.. figure:: screenshots/sphinx_rtd_theme_banner_old.png | ||
:target: _images/sphinx_rtd_theme_banner_old.png | ||
|
||
The message displayed when users are viewing docs from a tag and the :option:`--banner-main-ref` is a tag. Like the | ||
message above this one links users to the latest version of the current page. | ||
|
||
.. figure:: screenshots/sphinx_rtd_theme_banner_nourl.png | ||
:target: _images/sphinx_rtd_theme_banner_nourl.png | ||
|
||
An example of a banner message from a page that does not exist in the :option:`--banner-main-ref` version. Since | ||
there is no page to link to this is just text informing the user that they're viewing the development version of the | ||
docs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ Project Links | |
|
||
install | ||
tutorial | ||
banner | ||
settings | ||
context | ||
themes | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.scv-banner { | ||
padding: 3px; | ||
border-radius: 2px; | ||
font-size: 80%; | ||
text-align: center; | ||
color: white; | ||
background: #d40 linear-gradient(-45deg, | ||
rgba(255, 255, 255, 0.2) 0%, | ||
rgba(255, 255, 255, 0.2) 25%, | ||
transparent 25%, | ||
transparent 50%, | ||
rgba(255, 255, 255, 0.2) 50%, | ||
rgba(255, 255, 255, 0.2) 75%, | ||
transparent 75%, | ||
transparent | ||
); | ||
background-size: 28px 28px; | ||
} | ||
.scv-banner > a { | ||
color: white; | ||
} | ||
|
||
|
||
.scv-sphinx_rtd_theme { | ||
background-color: #2980B9; | ||
} | ||
|
||
|
||
.scv-bizstyle { | ||
background-color: #336699; | ||
} | ||
|
||
|
||
.scv-classic { | ||
text-align: center !important; | ||
} | ||
|
||
|
||
.scv-traditional { | ||
text-align: center !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{# Set banner color via CSS. #} | ||
{%- set banner_classes = 'scv-banner' %} | ||
{%- if html_theme in ('sphinx_rtd_theme', 'bizstyle', 'classic', 'traditional') %} | ||
{%- set banner_classes = banner_classes + ' scv-' + html_theme %} | ||
{%- endif %} | ||
|
||
{# Set banner message. #} | ||
{%- if scv_banner_main_version != current_version %} | ||
{# Determine base message. #} | ||
{%- if scv_is_branch %} | ||
{%- set banner_message = '<b>Warning:</b> This document is for the development version of %s.'|format(project) %} | ||
{%- else %} | ||
{%- set banner_message = '<b>Warning:</b> This document is for an old version of %s.'|format(project) %} | ||
{%- endif %} | ||
{# Determine URL of main version. #} | ||
{%- if vhasdoc(scv_banner_main_version) %} | ||
{%- set banner_message = '<a href="%s">' + banner_message + ' The %s version is %s.</a>' %} | ||
{%- if scv_banner_main_ref_is_tag %} | ||
{%- set banner_message = banner_message|format(vpathto(scv_banner_main_version), 'latest', scv_banner_main_version) %} | ||
{%- else %} | ||
{%- set banner_message = banner_message|format(vpathto(scv_banner_main_version), 'main', scv_banner_main_version) %} | ||
{%- endif %} | ||
{%- endif %} | ||
{%- endif %} | ||
|
||
{# Display banner. #} | ||
{% block banner %} | ||
{%- if banner_message %} | ||
<p class="{{ banner_classes }}">{{ banner_message }}</p> | ||
{%- endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{# Import the theme's layout. #} | ||
{% extends "!layout.html" %} | ||
|
||
{# Prepend banner to body. #} | ||
{%- set body %} | ||
{%- if scv_show_banner %}{%- include "banner.html" %}{% endif %} | ||
{%- block body %}{% endblock %} {# Sphinx overrides body block without calling super(). #} | ||
{% endset %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.