Debian Codegraph @

docs/customization.rst

raw
1 =============
2 Customization
3 =============
4
5 Alabaster's behavior & style can be customized in multiple ways:
6
7 * Various template-level or nontrivial-style settings can be configured via
8 your ``conf.py`` in ``html_theme_options``; see :ref:`theme-options`.
9 * As of Alabaster 0.7.8, you can provide your own CSS stylesheet overrides via
10 a :ref:`custom stylesheet <custom-stylesheet>`. This is suitable for changes
11 that only need minor CSS modifications.
12
13 .. note::
14 Some theme options implemented prior to 0.7.8 would have been more suitable
15 as local custom stylesheet overrides. Therefore:
16
17 * We no longer accept feature requests which are more appropriately solved
18 by using this functionality instead.
19 * In future backwards-incompatible versions we may deprecate some of those
20 options; as such we highly recommend leveraging the custom stylesheet
21 whenever possible, even if an option is present below.
22
23 * When in doubt, simply check `the built-in stylesheet's template
24 <https://github.com/sphinx-doc/alabaster/blob/master/alabaster/static/alabaster.css_t>`_
25 to see whether the option you're looking at is a basic variable
26 insertion or something more complicated.)
27
28
29 .. _custom-stylesheet:
30
31 Custom stylesheet
32 =================
33
34 If you need to modify Alabaster's default CSS styles in a way not covered by
35 the theme options from the next section, you may provide a custom CSS
36 stylesheet as follows:
37
38 * Create a file named ``custom.css`` anywhere you prefer (typically
39 ``_static/``, but this is solely convention) containing your desired
40 overrides to the CSS found in Alabaster's ``static/alabaster_css_t``.
41 * Set the core Sphinx option `html_static_path
42 <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path>`_
43 to either that file's path, or the directory it lives within.
44
45
46 .. _theme-options:
47
48 Theme options
49 =============
50
51 Alabaster's primary configuration route is the ``html_theme_options`` variable,
52 set in ``conf.py`` alongside the rest, e.g.:
53
54 .. code-block:: python
55
56 html_theme_options = {
57 'logo': 'logo.png',
58 'github_user': 'sphinx-doc',
59 'github_repo': 'alabaster',
60 }
61
62 The following subsections detail available such options, including notes about
63 behavior. Default values can be found by viewing `theme.conf
64 <https://github.com/sphinx-doc/alabaster/blob/master/alabaster/theme.conf>`_
65 directly.
66
67 Basics
68 ------
69
70 Settings related to text display, logo, etc.
71
72 * ``body_text_align``: Which CSS ``text-align`` value to use for body text
73 (if there is any.)
74 * ``canonical_url``: **Deprecated**, please use the html_baseurl_ Sphinx option instead.
75 If set, is used as the base URL (set before the relative
76 path/pagename) for a ``<link rel="canonical">`` `canonical URL
77 <https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls>`_ header tag.
78
79 .. note:: This value must end with a trailing slash.
80
81 .. _html_baseurl: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_baseurl
82
83 * ``description``: Text blurb about your project, to appear under the logo.
84 * ``description_font_style``: Which CSS ``font-style`` to use for description
85 text.
86 * ``fixed_sidebar``: Makes the sidebar 'fixed' or pinned in place, so that the
87 main body of the page scrolls but the sidebar remains visible. (Applies only
88 to desktop window sizes; the mobile view is unaffected.)
89 * ``logo``: Relative path (from ``$PROJECT/_static/``) to a logo image, which
90 will appear in the upper left corner above the name of the project.
91
92 * If ``logo`` is not set, your ``project`` name setting (from the top
93 level Sphinx config) will be used in a text header instead. This
94 preserves a link back to your homepage from inner doc pages.
95
96 * ``logo_name``: Set to ``True`` to insert your site's ``project`` name
97 under the logo image as text, or to any string to include arbitrary text.
98 Useful if your logo doesn't include the project name itself.
99 * ``logo_text_align``: Which CSS ``text-align`` value to use for logo text
100 (if there is any.)
101 * ``page_width``: CSS width specifier controlling default content/page width.
102 * ``sidebar_width``: CSS width specifier controlling default sidebar width.
103 * ``touch_icon``: Path to an image (as with ``logo``, relative to
104 ``$PROJECT/_static/``) to be used for an iOS application icon, for when
105 pages are saved to an iOS device's home screen via Safari.
106
107 Service links and badges
108 ------------------------
109
110 Third-party services (GitHub, Travis-CI, etc etc) and related badges or
111 banners.
112
113 * ``analytics_id``: Set to your `Google Analytics
114 <https://marketingplatform.google.com/about/analytics/>`_ ID (e.g. ``UA-#######-##``) to enable
115 tracking.
116 * ``badge_branch``: Set which branch is used in the Travis, CodeCov, etc
117 badges.
118 * ``codecov_button``: ``true``, ``false`` or a Github-style ``"account/repo"``
119 string - used to display a `Codecov <https://about.codecov.io>`_ build status
120 button in the sidebar. If ``true``, uses your ``github_(user|repo)``
121 settings.
122 * ``donate_url``: URL to generic/arbitrary donation service; causes display of
123 a basic 'Donate' badge/shield (from https://shields.io) linking to the URL
124 given.
125 * ``github_banner``: ``true`` or ``false`` - whether to apply a 'Fork me on
126 Github' banner in the top right corner of the page.
127
128 * If ``true``, requires that you set ``github_user`` and ``github_repo``
129 (see below).
130 * May also submit a string file path (as with ``logo``, relative to
131 ``$PROJECT/_static/``) to be used as the banner image instead of the
132 default.
133
134 * ``github_button``: ``true`` or ``false`` - whether to link to your Github.
135
136 * If ``true``, requires that you set ``github_user`` and ``github_repo``.
137 * There are also the ``github_type`` and ``github_count`` options, which
138 behave as described in `Github Buttons' documentation
139 <https://ghbtns.com>`_.
140
141 * ``github_repo``: Used by ``github_button`` and ``github_banner`` (see above);
142 does nothing if both of those are set to ``false``.
143 * ``github_user``: Used by ``github_button`` and ``github_banner`` (see above);
144 does nothing if both of those are set to ``false``.
145 * ``gittip_user`` / ``gratipay_user``: **Deprecated**, as that service is no
146 longer running. These options still exist (removing them would break
147 backwards compatibility; Sphinx errors when users try to set nonexistent
148 options) but they no longer do anything.
149 * ``tidelift_url``: Set this to your `Tidelift <https://tidelift.com/>`_
150 project URL if you want a "Professional support" section in your sidebar.
151
152 - If copying the URL straight from Tidelift's site, you'll probably want to
153 change ``&utm_campaign=readme`` to ``&utm_campaign=docs``.
154
155 * ``travis_button``: ``true``, ``false`` or a Github-style ``"account/repo"``
156 string - used to display a `Travis-CI <https://travis-ci.org>`_ build status
157 button in the sidebar. If ``true``, uses your ``github_(user|repo)``
158 settings.
159
160 Non-service sidebar control
161 ---------------------------
162
163 Sidebar-related options that aren't directly related to service links.
164
165 * ``extra_nav_links``: Dictionary mapping link names to link targets; these
166 will be added in a UL below the main sidebar navigation (provided you've
167 enabled ``navigation.html`` via the ``html_sidebars`` option; see
168 :doc:`installation`.) Useful for static links outside your Sphinx doctree.
169 * ``show_related``: Boolean controlling whether the sidebar
170 'next/previous/related' secondary navigation elements are hidden or
171 displayed. Defaults to ``false`` since on many sites these elements are
172 superfluous.
173
174 .. note::
175 This is distinct from the ``show_relbars`` setting found in the
176 header/footer options; the two visual components are orthogonal and may be
177 enabled/disabled independently of one another.
178
179 * ``sidebar_collapse``: Boolean determining whether all TOC entries that
180 are not ancestors of the current page are collapsed.
181 You can read more about this in the Sphinx toctree
182 `docs <https://www.sphinx-doc.org/en/master/development/templating.html#toctree>`_.
183 * ``sidebar_includehidden``: Boolean determining whether the TOC sidebar
184 should include hidden Sphinx toctree elements. Defaults to ``true`` so you
185 can use ``:hidden:`` in your index page's root toctree & avoid having 2x
186 copies of your navigation on your landing page.
187
188 Header/footer options
189 ---------------------
190
191 Which elements should appear in the header and/or footer, or modification of
192 same.
193
194 * ``show_powered_by``: Boolean controlling display of the ``Powered by
195 Sphinx N.N.N. & Alabaster M.M.M`` section of the footer. When ``true``, is
196 displayed next to the copyright information; when ``false``, is hidden.
197
198 .. deprecated:: 0.17.14
199 Set ``html_show_sphinx`` to ``True`` or ``False`` in ``conf.py`` instead.
200
201 * ``show_relbars``: ``true`` or ``false`` - used to display *next* and
202 *previous* links above and below the main page content. If you only want to
203 display one, this setting can be further overridden through the
204 ``show_relbar_top`` and ``show_relbar_bottom`` settings.
205
206 .. note::
207 This is distinct from the ``show_related`` setting found in the sidebar
208 control options, which controls sidebar-only next/previous links.
209
210 Style colors
211 ------------
212
213 These should be fully qualified CSS color specifiers such as ``#004B6B`` or
214 ``#444``. The first few items in the list are "global" colors used as defaults
215 for many of the others; update these to make sweeping changes to the
216 colorscheme. The more granular settings can be used to override as needed.
217
218 * ``anchor``: Foreground color of section anchor links (the 'paragraph'
219 symbol that shows up when you mouseover page section headers.)
220 * ``anchor_hover_bg``: Background color of ``anchor`` text.
221 * ``anchor_hover_fg``: Foreground color of section anchor links (as above)
222 when moused over.
223 * ``body_text``: Main content text.
224 * ``code_highlight``: Color of highlight when using ``:emphasize-lines:`` in a code block.
225 * ``footer_text``: Footer text (includes links.)
226 * ``footnote_bg``: Background of footnote blocks.
227 * ``footnote_border``: Border of same.
228 * ``gray_1``: Dark gray.
229 * ``gray_2``: Light gray.
230 * ``gray_3``: Medium gray.
231 * ``link_hover``: Body links, hovered.
232 * ``link``: Non-hovered body links.
233 * ``narrow_sidebar_bg``: Background of 'sidebar' when narrow window forces
234 it to the bottom of the page.
235 * ``narrow_sidebar_fg``: Text color of same.
236 * ``narrow_sidebar_link``: Link color of same.
237 * ``note_bg``: Background of ``.. note::`` blocks.
238 * ``note_border``: Border of same.
239 * ``pink_1``: Light pink.
240 * ``pink_2``: Medium pink.
241 * ``pre_bg``: Background of preformatted text blocks (including code
242 snippets.)
243 * ``relbar_border``: Color of border between bar holding *next* and *previous*
244 links, and the rest of the page content.
245 * ``seealso_bg``: Background of ``.. seealso::`` blocks.
246 * ``seealso_border``: Border of same.
247 * ``sidebar_header``: Sidebar headers.
248 * ``sidebar_hr``: Color of sidebar horizontal rule dividers.
249 * ``sidebar_link``: Sidebar links (there is no hover variant.) Applies to
250 both header & text links.
251 * ``sidebar_list``: Foreground color of sidebar list bullets & unlinked text.
252 * ``sidebar_link_underscore``: Sidebar links' underline (technically a
253 bottom-border).
254 * ``sidebar_search_button``: Background color of the search field's 'Go'
255 button.
256 * ``sidebar_text``: Sidebar paragraph text.
257 * ``warn_bg``: Background of ``.. warn::`` blocks.
258 * ``warn_border``: Border of same.
259
260 Fonts
261 -----
262
263 * ``caption_font_size``: Font size of caption block text.
264 * ``caption_font_family``: Font family of caption block text.
265 * ``code_font_size``: Font size of code block text.
266 * ``code_font_family``: Font family of code block text. Defaults to
267 ``'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono',
268 monospace``.
269 * ``font_family``: Font family of body text.
270 * ``font_size``: Font size of body text.
271 * ``head_font_family``: Font family of headings. Defaults to ``'Garamond',
272 'Georgia', serif``.