irrational is a visually (c)lean, responsive, configurable theme for the Sphinx documentation system. It is Python 2+3 compatible.
It began as a third-party theme for https://lab.errorist.xyz projects.
Live example of this theme can be seen on overdub project.
A changelog can be found at the bottom of this page.
Specifically, as compared to Kenneth's theme:
- Easy ability to install/use as a Python package (tip o' the hat to Dave & Eric's sphinx_rtd_theme for showing the way);
- Style tweaks, such as better code-block alignment, Github button placement, page source link moved to footer, improved (optional) related-items sidebar item, etc;
- Many customization hooks, including toggle of various sidebar & footer components; header/link/etc color control; etc;
- Improved documentation for all customizations (pre-existing & new).
The bare minimum required to install is as follows:
pip install irrational
(or equivalent).Enable the 'irrational' theme, mini-extension, and sidebar templates in your
conf.py
:import irrational html_theme_path = [irrational.get_path()] extensions = ['irrational'] html_theme = 'irrational' html_sidebars = { '**': [ 'about.html', 'navigation.html', 'relations.html', 'searchbox.html', 'donate.html', ] }
That's it! You now have the standard irrational theme set up. Read on for more configuration options/concerns.
The function irrational.get_path
dynamically returns irrational's install
location, ensuring that Sphinx can find and load it regardless of where/how
you installed irrational. Using it is highly recommended.
If you've manually installed irrational and/or are doing funky things to your
PYTHONPATH, you may need to replace the irrational.get_path()
call with your
own explicit string, as per the Sphinx config docs.
Feel free to adjust html_sidebars
as desired - the theme is designed
assuming you'll always have about.html
activated, but otherwise it doesn't
care much.
- See the Sphinx docs for details on how this setting behaves.
- irrational provides
about.html
(logo, github button + blurb),donate.html
(Gratipay blurb/button) andnavigation.html
(a more flexible version of the builtinlocaltoc
/globaltoc
templates).searchbox.html
comes with Sphinx itself.
If you're using either of the image-related options outlined below (logo
or
touch-icon
), you'll also want to tell Sphinx where to get your images from.
If so, add a line like this (changing the path if necessary; see the Sphinx
docs for 'html_static_path'):
html_static_path = ['_static']
irrational's primary configuration route is the html_theme_options
variable,
set in conf.py
alongside the rest. A brief example (note: snippet doesn't
include all possible options, see following list!):
html_theme_options = {
'logo': 'logo.png',
'github_user': 'bitprophet',
'github_repo': 'irrational',
}
logo
: Relative path (from$PROJECT/_static/
) to a logo image, which will appear in the upper left corner above the name of the project.- If
logo
is not set, yourproject
name setting (from the top level Sphinx config) will be used in a text header instead. This preserves a link back to your homepage from inner doc pages.
- If
logo_name
: Set totrue
to insert your site'sproject
name under the logo image as text. Useful if your logo doesn't include the project name itself. Defaults tofalse
.logo_text_align
: Which CSStext-align
value to use for logo text (if there is any.)body_text_align
: Which CSStext-align
value to use for body text (if there is any.)description
: Text blurb about your project, to appear under the logo.description_font_style
: Which CSSfont-style
to use for description text. Defaults tonormal
.github_user
,github_repo
: Used bygithub_button
andgithub_banner
(see below); does nothing if both of those are set tofalse
.github_button
:true
orfalse
(default:true
) - whether to link to your Github.If
true
, requires that you setgithub_user
andgithub_repo
.See also these other related options, which behave as described in Github Buttons' README:
github_type
: Defaults towatch
.github_count
: Defaults totrue
.
github_banner
:true
orfalse
(default:false
) - whether to apply a 'Fork me on Github' banner in the top right corner of the page.- If
true
, requires that you setgithub_user
andgithub_repo
. - May also submit a string file path (as with
logo
, relative to$PROJECT/_static/
) to be used as the banner image instead of the default.
- If
travis_button
:true
,false
or a Github-style"account/repo"
string - used to display a Travis-CI build status button in the sidebar. Iftrue
, uses yourgithub_(user|repo)
settings; defaults tofalse.
codecov_button
:true
,false
or a Github-style"account/repo"
string - used to display a Codecov build status button in the sidebar. Iftrue
, uses yourgithub_(user|repo)
settings; defaults tofalse.
gratipay_user
: Set to your Gratipay username if you want a Gratipay 'Donate' section in your sidebar.- This used to be
gittip_user
before that service changed its name to Gratipay; we've left the old setting in place as an alias for backwards compatibility reasons. It may be removed in the future. - If both options are given,
gratipay_user
wins.
- This used to be
analytics_id
: Set to your Google Analytics ID (e.g.UA-#######-##
) to enable tracking.touch_icon
: Path to an image (as withlogo
, relative to$PROJECT/_static/
) to be used for an iOS application icon, for when pages are saved to an iOS device's home screen via Safari.extra_nav_links
: Dictionary mapping link names to link targets; these will be added in a UL below the main sidebar navigation (provided you've enablednavigation.html
.) Useful for static links outside your Sphinx doctree.sidebar_includehidden
: Boolean determining whether the TOC sidebar should include hidden Sphinx toctree elements. Defaults totrue
so you can use:hidden:
in your index page's root toctree & avoid having 2x copies of your navigation on your landing page.show_powered_by
: Boolean controlling display of thePowered by Sphinx N.N.N. & irrational M.M.M
section of the footer. Whentrue
, is displayed next to the copyright information; whenfalse
, is hidden.show_related
: Boolean controlling whether the 'next/previous/related' secondary navigation elements are hidden or displayed. Defaults tofalse
since on many sites these elements are superfluous.page_width
: CSS width specifier controlling default content/page width. Defaults to940px
.sidebar_width
: CSS width specifier controlling default sidebar width. Defaults to220px
.
These should be fully qualified CSS color specifiers such as #004B6B
or
#444
. The first few items in the list are "global" colors used as defaults
for many of the others; update these to make sweeping changes to the
colorscheme. The more granular settings can be used to override as needed.
gray_1
: Dark gray.gray_2
: Light gray.gray_3
: Medium gray.pink_1
: Light pink.pink_2
: Medium pink.body_text
: Main content text.footer_text
: Footer text (includes links.)link
: Non-hovered body links.link_hover
: Body links, hovered.sidebar_header
: Sidebar headers. Defaults togray_1
.sidebar_text
: Sidebar paragraph text.sidebar_link
: Sidebar links (there is no hover variant.) Applies to both header & text links. Defaults togray_1
.sidebar_link_underscore
: Sidebar links' underline (technically a bottom-border).sidebar_search_button
: Background color of the search field's 'Go' button.sidebar_list
: Foreground color of sidebar list bullets & unlinked text.sidebar_hr
: Color of sidebar horizontal rule dividers. Defaults togray_3
.anchor
: Foreground color of section anchor links (the 'paragraph' symbol that shows up when you mouseover page section headers.)anchor_hover_fg
: Foreground color of section anchor links (as above) when moused over. Defaults togray_1
.anchor_hover_bg
: Background color of above.note_bg
: Background of.. note::
blocks. Defaults togray_2
.note_border
: Border of same.seealso_bg
: Background of.. seealso::
blocks. Defaults togray_2
.seealso_border
: Border of same.warn_bg
: Background of.. warn::
blocks. Defaults topink_1
.warn_border
: Border of same. Defaults topink_2
.footnote_bg
: Background of footnote blocks.footnote_border
: Border of same. Defaults togray_2
.pre_bg
: Background of preformatted text blocks (including code snippets.) Defaults togray_2
.narrow_sidebar_bg
: Background of 'sidebar' when narrow window forces it to the bottom of the page.narrow_sidebar_fg
: Text color of same.narrow_sidebar_link
: Link color of same. Defaults togray_3
.code_highlight
: Color of highlight when using:emphasize-lines:
in a code block.
font_family
: Font family of body text. Defaults to'goudy old style', 'minion pro', 'bell mt', Georgia, 'Hiragino Mincho Pro', serif
.head_font_family
: Font family of headings. Defaults to'Garamond', 'Georgia', serif
.code_font_size
: Font size of code block text. Defaults to0.9em
.code_font_family
: Font family of code block text. Defaults to'Consolas', 'Menlo', 'Deja Vu Sans Mono', 'Bitstream Vera Sans Mono', monospace
.
irrational is a modified version of Jeff Forcier's "Alabaster" Sphinx theme, based on a modified (with permission) version of Kenneth Reitz's "krTheme" Sphinx theme (it's the one used in his Requests project). Kenneth's theme was itself originally based on Armin Ronacher's Flask theme. Many thanks to both for their hard work.
- irrational use Overpass font.
- Start project.