Debian Codegraph @

docs/configuring.rst

raw
1 *************
2 Configuration
3 *************
4
5 Theme options
6 =============
7
8 The following options can be defined in your project's ``conf.py`` file, using
9 the :confval:`html_theme_options <sphinx:html_theme_options>` configuration option.
10
11 For example:
12
13 .. code:: python
14
15 html_theme_options = {
16 'analytics_id': 'G-XXXXXXXXXX', # Provided by Google in your dashboard
17 'analytics_anonymize_ip': False,
18 'logo_only': False,
19 'prev_next_buttons_location': 'bottom',
20 'style_external_links': False,
21 'vcs_pageview_mode': '',
22 'style_nav_header_background': 'white',
23 'flyout_display': 'hidden',
24 'version_selector': True,
25 'language_selector': True,
26 # Toc options
27 'collapse_navigation': True,
28 'sticky_navigation': True,
29 'navigation_depth': 4,
30 'includehidden': True,
31 'titles_only': False
32 }
33
34 Table of contents options
35 -------------------------
36
37 The following options change how :rst:dir:`sphinx:toctree` directives generate
38 documentation navigation.
39
40 .. confval:: collapse_navigation
41
42 With this enabled, navigation entries are not expandable -- the ``[+]``
43 icons next to each entry are removed.
44
45 :type: boolean
46 :default: ``True``
47
48 .. note::
49 Setting :confval:`collapse_navigation` to ``False`` and using a high value
50 for :confval:`navigation_depth` on projects with many files and a deep file
51 structure can cause long compilation times and can result in HTML files that
52 are significantly larger in file size.
53
54 .. confval:: sticky_navigation
55
56 Scroll the navigation with the main page content as you scroll the page.
57
58 :type: boolean
59 :default: ``True``
60
61 .. confval:: navigation_depth
62
63 The maximum depth of the table of contents tree. Set
64 this to ``-1`` to allow unlimited depth.
65
66 :type: integer
67 :default: ``4``
68
69 .. confval:: includehidden
70
71 Specifies if the navigation includes hidden table(s) of contents -- that is,
72 any :rst:dir:`sphinx:toctree` directive that is marked with the ``:hidden:``
73 option.
74
75 :type: boolean
76 :default: ``True``
77
78 .. confval:: titles_only
79
80 When enabled, page subheadings are not included in the
81 navigation.
82
83 :type: boolean
84 :default: False
85
86 .. _table of contents configuration options: http://www.sphinx-doc.org/en/stable/templating.html#toctree
87
88
89 ..
90 TODO
91 .
92 HTML context options
93 ~~~~~~~~~~~~~~~~~~~~
94
95
96 Miscellaneous options
97 ---------------------
98
99 .. confval:: analytics_id
100
101 If specified, Google Analytics' `gtag.js`_ is included in your pages.
102 Set the value to the ID provided to you by google (like ``UA-XXXXXXX`` or ``G-XXXXXXXXXX``).
103
104 :type: string
105
106 .. deprecated:: 3.0.0
107 The ``analytics_id`` option is deprecated, use the sphinxcontrib-googleanalytics_ extension instead.
108
109 .. _gtag.js: https://developers.google.com/gtagjs
110 .. _sphinxcontrib-googleanalytics: https://pypi.org/project/sphinxcontrib-googleanalytics/
111
112 .. confval:: analytics_anonymize_ip
113
114 Anonymize visitor IP addresses in Google Analytics.
115
116 :type: boolean
117 :default: ``False``
118
119 .. deprecated:: 3.0.0
120 The ``analytics_anonymize_ip`` option is deprecated, use the sphinxcontrib-googleanalytics_ extension instead.
121
122 .. confval:: canonical_url
123
124 This will specify a `canonical URL`_ meta link element to tell search
125 engines which URL should be ranked as the primary URL for your
126 documentation. This is important if you have multiple URLs that your
127 documentation is available through. The URL points to the root path of the
128 documentation and requires a trailing slash.
129
130 :type: URL
131
132 .. deprecated:: 0.6.0
133
134 Use :confval:`sphinx:html_baseurl` instead.
135
136 .. _canonical URL: https://en.wikipedia.org/wiki/Canonical_link_element
137
138 .. confval:: display_version
139
140 If ``True``, the version number is shown at the top of the sidebar.
141
142 :type: boolean
143 :default: ``False``
144
145 .. deprecated:: 3.0.0
146
147 Removed in favor of ``version_selector`` and ``language_selector``.
148
149 .. confval:: logo_only
150
151 Only display the logo image, do not display the project name at the top of
152 the sidebar
153
154 :type: boolean
155 :default: ``False``
156
157 .. confval:: prev_next_buttons_location
158
159 Location to display :guilabel:`Next` and :guilabel:`Previous` buttons. This
160 can be either ``bottom``, ``top``, ``both`` , or ``None``.
161
162 :type: string
163 :default: ``bottom``
164
165 .. confval:: style_external_links
166
167 Add an icon next to external links.
168
169 :type: boolean
170 :default: ``False``
171
172 .. confval:: vcs_pageview_mode
173
174 Changes how to view files when using ``display_github``, ``display_gitlab``,
175 etc. When using GitHub or GitLab this can be: ``blob`` (default), ``edit``,
176 or ``raw``. On Bitbucket, this can be either: ``view`` (default) or
177 ``edit``.
178
179 :type: string
180 :default: ``blob`` or ``view``
181
182 .. confval:: style_nav_header_background
183
184 Changes the background of the search area in the navigation bar. The value
185 can be anything valid in a CSS `background` property.
186
187 :type: string
188 :default: ``#2980B9``
189
190 .. confval:: flyout_display
191
192 Specify how to display the flyout (language and version selector).
193 This can be either ``attached`` or ``hidden``.
194 ``attached`` means that it will show the flyout in the bottom of the sidebar.
195 You will need to disable the default `Read the Docs flyout <https://docs.readthedocs.io/en/stable/flyout-menu.html>`_ in order to not have 2 flyouts showing.
196
197 :type: str
198 :default: ``hidden``
199
200 .. confval:: version_selector
201
202 Display a version selector below the title.
203 This feature makes usage of `Read the Docs Addons <https://docs.readthedocs.io/page/addons.html>`_ for this,
204 so it's required the documentation to be hosted on Read the Docs.
205 It only appears when there are more than 1 active version.
206
207 :type: boolean
208 :default: ``True``
209
210 .. confval:: language_selector
211
212 Display a language selector below the title.
213 This feature makes usage of `Read the Docs Addons <https://docs.readthedocs.io/page/addons.html>`_ for this,
214 so it's required the documentation to be served on Read the Docs.
215 It only appears when there is more than 1 active language.
216
217 :type: boolean
218 :default: ``True``
219
220
221 File-wide metadata
222 ==================
223
224 The following options can be used as :ref:`file-wide metadata
225 <sphinx:metadata>`:
226
227 .. confval:: github_url
228
229 Force the :guilabel:`Edit on GitHub` button to use the configured URL.
230
231 .. confval:: bitbucket_url
232
233 Force the :guilabel:`Edit on Bitbucket` button to use the configured URL.
234
235 .. confval:: gitlab_url
236
237 Force the :guilabel:`Edit on GitLab` button to use the configured URL.
238
239 Other configuration
240 ===================
241
242 Adding a logo
243 -------------
244
245 Using the Sphinx standard option :py:confval:`html_logo <sphinx:html_logo>`,
246 you can set an image file to be used as a logo at the top of the sidebar. The
247 theme option :py:confval:`logo_only` also allows for *only* the logo to be shown
248 at the top of the sidebar.
249
250 Adding custom CSS or Javascript
251 -------------------------------
252
253 Adding custom CSS or Javascript can help you alter the look and feel of this
254 theme without forking the theme for local use.
255
256 In order to add custom CSS or Javascript without disrupting the existing theme
257 files, you can :doc:`add files to be included in your documentation output
258 <rtd:guides/adding-custom-css>`.
259
260 How the table of contents displays
261 ==================================
262
263 Currently the left menu will build based upon any ``toctree`` directives defined
264 in your source files. It outputs 4 levels of depth by default, to allow for
265 quick navigation through topics. If no TOC trees are defined, Sphinx's default
266 behavior is to use the page headings instead.
267
268 It's important to note that if you don't follow the same styling for your reST
269 headings across your documents, the TOC tree will build incorrectly, and the
270 resulting menu might not show the correct depth when it renders.
271
272 Also note that by default the table of contents is set with
273 ``includehidden=True``. This allows you to set a hidden TOC in your index file
274 with the :ref:`:hidden: <sphinx:toctree-directive>` property that will allow you
275 to build a TOC without it rendering in your index.
276
277 By default, the navigation will "stick" to the screen as you scroll. However if
278 your TOC is not tall enough, it will revert to static positioning. To disable the
279 sticky navigation altogether, change the :confval:`sticky_navigation` theme option.