Add date and git information to version
[cacert-infradocs.git] / docs / conf.py
1 # -*- coding: utf-8 -*-
2 #
3 # CAcert infrastructure documentation build configuration file, created by
4 # sphinx-quickstart on Wed Apr 13 19:34:10 2016.
5 #
6 # This file is execfile()d with the current directory set to its
7 # containing dir.
8 #
9 # Note that not all possible configuration values are present in this
10 # autogenerated file.
11 #
12 # All configuration values have a default; values that are commented out
13 # serve to show the default.
14
15 import sys
16 import os
17 from datetime import datetime
18 from urllib.parse import urljoin
19
20 from git import repo
21 from docutils import nodes, utils
22
23 # If extensions (or modules to document with autodoc) are in another directory,
24 # add these directories to sys.path here. If the directory is relative to the
25 # documentation root, use os.path.abspath to make it absolute, like shown here.
26 sys.path.insert(0, os.path.abspath('.'))
27
28 # -- General configuration ------------------------------------------------
29
30 # If your documentation needs a minimal Sphinx version, state it here.
31 #needs_sphinx = '1.0'
32
33 # Add any Sphinx extension module names here, as strings. They can be
34 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
35 # ones.
36 extensions = [
37 'sphinx.ext.todo',
38 'sphinx.ext.extlinks',
39 'jandd.sphinxext.ip',
40 'jandd.sphinxext.mac',
41 'sphinxext.cacert',
42 ]
43
44 # Add any paths that contain templates here, relative to this directory.
45 templates_path = ['_templates']
46
47 # The suffix(es) of source filenames.
48 # You can specify multiple suffix as a list of string:
49 # source_suffix = ['.rst', '.md']
50 source_suffix = '.rst'
51
52 # The encoding of source files.
53 #source_encoding = 'utf-8-sig'
54
55 # The master toctree document.
56 master_doc = 'index'
57
58 # General information about the project.
59 project = u'CAcert infrastructure'
60 copyright = u'2016, 2017, 2018 Jan Dittberner, CAcert'
61 author = u'CAcert infrastructure team'
62
63 # The version info for the project you're documenting, acts as replacement for
64 # |version| and |release|, also used in various other places throughout the
65 # built documents.
66 #
67 # The short X.Y version.
68 version = u'0.1'
69 # The full version, including alpha/beta/rc tags.
70 release = "{}-git:{} built:{}".format(
71 version,
72 repo.Repo('..').git.describe('--always', '--dirty'),
73 datetime.utcnow().replace(microsecond=0))
74
75 # The language for content autogenerated by Sphinx. Refer to documentation
76 # for a list of supported languages.
77 #
78 # This is also used if you do content translation via gettext catalogs.
79 # Usually you set "language" from the command line for these cases.
80 language = None
81
82 # There are two options for replacing |today|: either, you set today to some
83 # non-false value, then it is used:
84 #today = ''
85 # Else, today_fmt is used as the format for a strftime call.
86 #today_fmt = '%B %d, %Y'
87
88 # List of patterns, relative to source directory, that match files and
89 # directories to ignore when looking for source files.
90 exclude_patterns = ['_build', 'systems/template.rst', 'critical/template.rst']
91
92 # The reST default role (used for this markup: `text`) to use for all
93 # documents.
94 #default_role = None
95
96 # If true, '()' will be appended to :func: etc. cross-reference text.
97 #add_function_parentheses = True
98
99 # If true, the current module name will be prepended to all description
100 # unit titles (such as .. function::).
101 #add_module_names = True
102
103 # If true, sectionauthor and moduleauthor directives will be shown in the
104 # output. They are ignored by default.
105 #show_authors = False
106
107 # The name of the Pygments (syntax highlighting) style to use.
108 pygments_style = 'sphinx'
109
110 # A list of ignored prefixes for module index sorting.
111 #modindex_common_prefix = []
112
113 # If true, keep warnings as "system message" paragraphs in the built documents.
114 #keep_warnings = False
115
116 # If true, `todo` and `todoList` produce output, else they produce nothing.
117 todo_include_todos = True
118
119
120 # -- Options for HTML output ----------------------------------------------
121
122 # The theme to use for HTML and HTML Help pages. See the documentation for
123 # a list of builtin themes.
124 html_theme = 'classic'
125
126 # Theme options are theme-specific and customize the look and feel of a theme
127 # further. For a list of options available for each theme, see the
128 # documentation.
129 html_theme_options = {
130 'sidebarbgcolor': '#f5f7f7',
131 'sidebartextcolor': '#334d55',
132 'sidebarlinkcolor': '#005fa9',
133 }
134
135 # Add any paths that contain custom themes here, relative to this directory.
136 #html_theme_path = []
137
138 # The name for this set of Sphinx documents. If None, it defaults to
139 # "<project> v<release> documentation".
140 html_title = project + " documentation v" + release
141
142 # A shorter title for the navigation bar. Default is the same as html_title.
143 #html_short_title = None
144
145 # The name of an image file (relative to this directory) to place at the top
146 # of the sidebar.
147 html_logo = os.path.join('images', 'CAcert-logo-colour.svg')
148
149 # The name of an image file (relative to this directory) to use as a favicon of
150 # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
151 # pixels large.
152 html_favicon = os.path.join('images', 'favicon.ico')
153
154 # Add any paths that contain custom static files (such as style sheets) here,
155 # relative to this directory. They are copied after the builtin static files,
156 # so a file named "default.css" will overwrite the builtin "default.css".
157 html_static_path = ['_static']
158
159 # Add any extra paths that contain custom files (such as robots.txt or
160 # .htaccess) here, relative to this directory. These files are copied
161 # directly to the root of the documentation.
162 #html_extra_path = []
163
164 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
165 # using the given strftime format.
166 #html_last_updated_fmt = '%b %d, %Y'
167
168 # If true, SmartyPants will be used to convert quotes and dashes to
169 # typographically correct entities.
170 #html_use_smartypants = True
171
172 # Custom sidebar templates, maps document names to template names.
173 #html_sidebars = {}
174
175 # Additional templates that should be rendered to pages, maps page names to
176 # template names.
177 #html_additional_pages = {}
178
179 # If false, no module index is generated.
180 #html_domain_indices = True
181
182 # If false, no index is generated.
183 #html_use_index = True
184
185 # If true, the index is split into individual pages for each letter.
186 #html_split_index = False
187
188 # If true, links to the reST sources are added to the pages.
189 #html_show_sourcelink = True
190
191 # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
192 #html_show_sphinx = True
193
194 # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
195 #html_show_copyright = True
196
197 # If true, an OpenSearch description file will be output, and all pages will
198 # contain a <link> tag referring to it. The value of this option must be the
199 # base URL from which the finished HTML is served.
200 #html_use_opensearch = ''
201
202 # This is the file name suffix for HTML files (e.g. ".xhtml").
203 #html_file_suffix = None
204
205 # Language to be used for generating the HTML full-text search index.
206 # Sphinx supports the following languages:
207 # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
208 # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
209 #html_search_language = 'en'
210
211 # A dictionary with options for the search language support, empty by default.
212 # Now only 'ja' uses this config value
213 #html_search_options = {'type': 'default'}
214
215 # The name of a javascript file (relative to the configuration directory) that
216 # implements a search results scorer. If empty, the default will be used.
217 #html_search_scorer = 'scorer.js'
218
219 # Output file base name for HTML help builder.
220 htmlhelp_basename = 'CAcertinfrastructuredoc'
221
222 # -- Options for LaTeX output ---------------------------------------------
223
224 latex_elements = {
225 # The paper size ('letterpaper' or 'a4paper').
226 #'papersize': 'letterpaper',
227
228 # The font size ('10pt', '11pt' or '12pt').
229 #'pointsize': '10pt',
230
231 # Additional stuff for the LaTeX preamble.
232 #'preamble': '',
233
234 # Latex figure (float) alignment
235 #'figure_align': 'htbp',
236 }
237
238 # Grouping the document tree into LaTeX files. List of tuples
239 # (source start file, target name, title,
240 # author, documentclass [howto, manual, or own class]).
241 latex_documents = [
242 (master_doc, 'CAcertinfrastructure.tex', u'CAcert infrastructure Documentation',
243 u'Jan Dittberner', 'manual'),
244 ]
245
246 # The name of an image file (relative to this directory) to place at the top of
247 # the title page.
248 #latex_logo = None
249
250 # For "manual" documents, if this is true, then toplevel headings are parts,
251 # not chapters.
252 #latex_use_parts = False
253
254 # If true, show page references after internal links.
255 #latex_show_pagerefs = False
256
257 # If true, show URL addresses after external links.
258 #latex_show_urls = False
259
260 # Documents to append as an appendix to all manuals.
261 #latex_appendices = []
262
263 # If false, no module index is generated.
264 #latex_domain_indices = True
265
266
267 # -- Options for manual page output ---------------------------------------
268
269 # One entry per manual page. List of tuples
270 # (source start file, name, description, authors, manual section).
271 man_pages = [
272 (master_doc, 'cacertinfrastructure', u'CAcert infrastructure Documentation',
273 [author], 1)
274 ]
275
276 # If true, show URL addresses after external links.
277 #man_show_urls = False
278
279
280 # -- Options for Texinfo output -------------------------------------------
281
282 # Grouping the document tree into Texinfo files. List of tuples
283 # (source start file, target name, title, author,
284 # dir menu entry, description, category)
285 texinfo_documents = [
286 (master_doc, 'CAcertinfrastructure', u'CAcert infrastructure Documentation',
287 author, 'CAcertinfrastructure', 'One line description of project.',
288 'Miscellaneous'),
289 ]
290
291 # Documents to append as an appendix to all manuals.
292 #texinfo_appendices = []
293
294 # If false, no module index is generated.
295 #texinfo_domain_indices = True
296
297 # How to display URL addresses: 'footnote', 'no', or 'inline'.
298 #texinfo_show_urls = 'footnote'
299
300 # If true, do not generate a @detailmenu in the "Top" node's menu.
301 #texinfo_no_detailmenu = False
302
303
304 # -- Options for Epub output ----------------------------------------------
305
306 # Bibliographic Dublin Core info.
307 epub_title = project
308 epub_author = author
309 epub_publisher = author
310 epub_copyright = copyright
311
312 # The basename for the epub file. It defaults to the project name.
313 #epub_basename = project
314
315 # The HTML theme for the epub output. Since the default themes are not
316 # optimized for small screen space, using the same theme for HTML and epub
317 # output is usually not wise. This defaults to 'epub', a theme designed to save
318 # visual space.
319 #epub_theme = 'epub'
320
321 # The language of the text. It defaults to the language option
322 # or 'en' if the language is not set.
323 #epub_language = ''
324
325 # The scheme of the identifier. Typical schemes are ISBN or URL.
326 #epub_scheme = ''
327
328 # The unique identifier of the text. This can be a ISBN number
329 # or the project homepage.
330 #epub_identifier = ''
331
332 # A unique identification for the text.
333 #epub_uid = ''
334
335 # A tuple containing the cover image and cover page html template filenames.
336 #epub_cover = ()
337
338 # A sequence of (type, uri, title) tuples for the guide element of content.opf.
339 #epub_guide = ()
340
341 # HTML files that should be inserted before the pages created by sphinx.
342 # The format is a list of tuples containing the path and title.
343 #epub_pre_files = []
344
345 # HTML files that should be inserted after the pages created by sphinx.
346 # The format is a list of tuples containing the path and title.
347 #epub_post_files = []
348
349 # A list of files that should not be packed into the epub file.
350 epub_exclude_files = ['search.html']
351
352 # The depth of the table of contents in toc.ncx.
353 #epub_tocdepth = 3
354
355 # Allow duplicate toc entries.
356 #epub_tocdup = True
357
358 # Choose between 'default' and 'includehidden'.
359 #epub_tocscope = 'default'
360
361 # Fix unsupported image types using the Pillow.
362 #epub_fix_images = False
363
364 # Scale large images.
365 #epub_max_image_width = 0
366
367 # How to display URL addresses: 'footnote', 'no', or 'inline'.
368 #epub_show_urls = 'inline'
369
370 # If false, no index is generated.
371 #epub_use_index = True
372
373
374 extlinks = {
375 'wiki': ('https://wiki.cacert.org/%s', 'Wiki '),
376 }
377
378
379 def cacert_bug(name, rawtext, text, lineno, inliner, options={}, content=[]):
380 try:
381 bugnum = int(text)
382 if bugnum <= 0:
383 raise ValueError
384 except ValueError:
385 msg = inliner.reporter.error(
386 'Bug number must be a number greater than or equal to 1; '
387 '"%s" is invalid.' % text, line=lineno)
388 prb = inliner.problematic(rawtext, rawtext, msg)
389 return [prb], [msg]
390 ref = 'https://bugs.cacert.org/view.php?id=%d' % bugnum
391 node = nodes.reference(rawtext, '#' + utils.unescape(text), refuri=ref,
392 **options)
393 return [node], []
394
395
396 def setup(app):
397 app.add_role('bug', cacert_bug)