From 35c795c05c2aa7b06722ab3860fd6907d8a8fc77 Mon Sep 17 00:00:00 2001 From: Bernd Bausch Date: Fri, 6 Mar 2015 20:08:54 +0900 Subject: [PATCH] Rendering admonitions with Font Awesome icons For documentation based on restructured text (RST), notes, warnings and important remarks, in RST jargon "admonitions", need to be rendered differently than Sphinx does it by default. Specifically: - admonition boxes require certain colour - box titles "Note", "Warning", "Important" or their i18n equivalents must be bold, - Font Awesome icons decorate the boxes Colour and Boldness are easily fixed in the combined.css file. Icons are added by jQuery code. Example: this RST code .. note:: some text here is rendered by Sphinx as:

Note

some text here

To add the appropriate Font Awesome icon, the second line needs to be:

Note

This is achieved by jQuery code in docs.js that adds the FA classes and puts a space in front of the title text. As a side effect of adding the FA classes, the admonition title font has become smaller. I have not found out what causes this, but it doesn't look too bad, so I keep it. An alternative to the jQuery method is writing a Sphinx extension to modify Sphinx output. While this is a more elegant solution (OK, elegance is in the eye of the beholder), it requires shipping additional code, is more difficult to understand and relies on Sphinx features that are not that well documented. Thus we abandoned this solution. In case someone wants to unearth it, it's available in patch set 4. Change-Id: I7f8bffd19ec2f8695cac09bc577aa6bac132dc20 Closes-Bug: #1416572 --- doc/source/conf.py | 1 - .../theme/openstackdocs/css.html | 10 ++++--- .../openstackdocs/static/css/combined.css | 26 +++++++++++++------ .../theme/openstackdocs/static/js/docs.js | 26 +++++++++++++++++++ 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index cca45ab..5b57504 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -30,7 +30,6 @@ import openstackdocstheme # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/openstackdocstheme/theme/openstackdocs/css.html b/openstackdocstheme/theme/openstackdocs/css.html index 10200c9..135595b 100644 --- a/openstackdocstheme/theme/openstackdocs/css.html +++ b/openstackdocstheme/theme/openstackdocs/css.html @@ -1,16 +1,18 @@ - - - - + + + + +