conf.py 10.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# pybind11 documentation build configuration file, created by
# sphinx-quickstart on Sun Oct 11 19:23:48 2015.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import shlex
19
import subprocess
20
21
22
23

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
24
# sys.path.insert(0, os.path.abspath('.'))
25
26
27
28

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
29
# needs_sphinx = '1.0'
30
31
32
33

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
34
35
36
37
38
extensions = [
    "breathe",
    "sphinxcontrib.rsvgconverter",
    "sphinxcontrib.moderncmakedomain",
]
39

40
41
42
breathe_projects = {"pybind11": ".build/doxygenxml/"}
breathe_default_project = "pybind11"
breathe_domain_by_extension = {"h": "cpp"}
43
44

# Add any paths that contain templates here, relative to this directory.
45
templates_path = [".templates"]
46
47
48
49

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# 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
60
61
project = "pybind11"
copyright = "2017, Wenzel Jakob"
author = "Wenzel Jakob"
62
63
64
65

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
66
67
68
69
70
71
72

# Read the listed version
with open("../pybind11/_version.py") as f:
    code = compile(f.read(), "../pybind11/_version.py", "exec")
loc = {}
exec(code, loc)

73
# The full version, including alpha/beta/rc tags.
74
version = loc["__version__"]
75
76
77
78
79
80
81
82
83
84

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
85
# today = ''
86
# Else, today_fmt is used as the format for a strftime call.
87
# today_fmt = '%B %d, %Y'
88
89
90

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
91
exclude_patterns = [".build", "release.rst"]
92
93
94

# The reST default role (used for this markup: `text`) to use for all
# documents.
95
default_role = "any"
96
97

# If true, '()' will be appended to :func: etc. cross-reference text.
98
# add_function_parentheses = True
99
100
101

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
102
# add_module_names = True
103
104
105

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
106
# show_authors = False
107
108

# The name of the Pygments (syntax highlighting) style to use.
109
# pygments_style = 'monokai'
110
111

# A list of ignored prefixes for module index sorting.
112
# modindex_common_prefix = []
113
114

# If true, keep warnings as "system message" paragraphs in the built documents.
115
# keep_warnings = False
116
117
118
119
120
121
122
123
124
125

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.

126
on_rtd = os.environ.get("READTHEDOCS", None) == "True"
127
128
129

if not on_rtd:  # only import and set the theme if we're building docs locally
    import sphinx_rtd_theme
130
131

    html_theme = "sphinx_rtd_theme"
132
    html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
133

134
    html_context = {"css_files": ["_static/theme_overrides.css"]}
135
136
else:
    html_context = {
137
138
139
140
        "css_files": [
            "//media.readthedocs.org/css/sphinx_rtd_theme.css",
            "//media.readthedocs.org/css/readthedocs-doc-embed.css",
            "_static/theme_overrides.css",
Wenzel Jakob's avatar
Wenzel Jakob committed
141
142
        ]
    }
143
144
145
146

# Theme options are theme-specific and customize the look and feel of a theme
# further.  For a list of options available for each theme, see the
# documentation.
147
# html_theme_options = {}
148
149

# Add any paths that contain custom themes here, relative to this directory.
150
# html_theme_path = []
151
152

# The name for this set of Sphinx documents.  If None, it defaults to
153
# "<project> v<version> documentation".
154
# html_title = None
155
156

# A shorter title for the navigation bar.  Default is the same as html_title.
157
# html_short_title = None
158
159
160

# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
161
# html_logo = None
162
163
164
165

# The name of an image file (within the static path) to use as favicon of the
# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
166
# html_favicon = None
167
168
169
170

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
171
html_static_path = ["_static"]
172
173
174
175

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
176
# html_extra_path = []
177
178
179

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
180
# html_last_updated_fmt = '%b %d, %Y'
181
182
183

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
184
# html_use_smartypants = True
185
186

# Custom sidebar templates, maps document names to template names.
187
# html_sidebars = {}
188
189
190

# Additional templates that should be rendered to pages, maps page names to
# template names.
191
# html_additional_pages = {}
192
193

# If false, no module index is generated.
194
# html_domain_indices = True
195
196

# If false, no index is generated.
197
# html_use_index = True
198
199

# If true, the index is split into individual pages for each letter.
200
# html_split_index = False
201
202

# If true, links to the reST sources are added to the pages.
203
# html_show_sourcelink = True
204
205

# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
206
# html_show_sphinx = True
207
208

# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
209
# html_show_copyright = True
210
211
212
213

# If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it.  The value of this option must be the
# base URL from which the finished HTML is served.
214
# html_use_opensearch = ''
215
216

# This is the file name suffix for HTML files (e.g. ".xhtml").
217
# html_file_suffix = None
218
219
220
221
222

# Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages:
#   'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
#   'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
223
# html_search_language = 'en'
224
225
226

# A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value
227
# html_search_options = {'type': 'default'}
228
229
230

# The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used.
231
# html_search_scorer = 'scorer.js'
232
233

# Output file base name for HTML help builder.
234
htmlhelp_basename = "pybind11doc"
235
236
237
238

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
239
240
241
242
243
244
    # The paper size ('letterpaper' or 'a4paper').
    # 'papersize': 'letterpaper',
    # The font size ('10pt', '11pt' or '12pt').
    # 'pointsize': '10pt',
    # Additional stuff for the LaTeX preamble.
    "preamble": r"""
245
246
\DeclareUnicodeCharacter{00A0}{}
\DeclareUnicodeCharacter{2194}{<->}
247
248
249
""",
    # Latex figure (float) alignment
    # 'figure_align': 'htbp',
250
251
252
253
254
255
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
#  author, documentclass [howto, manual, or own class]).
latex_documents = [
256
    (master_doc, "pybind11.tex", "pybind11 Documentation", "Wenzel Jakob", "manual"),
257
258
259
260
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
Wenzel Jakob's avatar
Wenzel Jakob committed
261
# latex_logo = 'pybind11-logo.png'
262
263
264

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
265
# latex_use_parts = False
266
267

# If true, show page references after internal links.
268
# latex_show_pagerefs = False
269
270

# If true, show URL addresses after external links.
271
# latex_show_urls = False
272
273

# Documents to append as an appendix to all manuals.
274
# latex_appendices = []
275
276

# If false, no module index is generated.
277
# latex_domain_indices = True
278
279
280
281
282
283


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
284
man_pages = [(master_doc, "pybind11", "pybind11 Documentation", [author], 1)]
285
286

# If true, show URL addresses after external links.
287
# man_show_urls = False
288
289
290
291
292
293
294
295


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
#  dir menu entry, description, category)
texinfo_documents = [
296
297
298
299
300
301
302
303
304
    (
        master_doc,
        "pybind11",
        "pybind11 Documentation",
        author,
        "pybind11",
        "One line description of project.",
        "Miscellaneous",
    ),
305
306
307
]

# Documents to append as an appendix to all manuals.
308
# texinfo_appendices = []
309
310

# If false, no module index is generated.
311
# texinfo_domain_indices = True
312
313

# How to display URL addresses: 'footnote', 'no', or 'inline'.
314
# texinfo_show_urls = 'footnote'
315
316

# If true, do not generate a @detailmenu in the "Top" node's menu.
317
# texinfo_no_detailmenu = False
318

319
320
primary_domain = "cpp"
highlight_language = "cpp"
321
322
323


def generate_doxygen_xml(app):
324
    build_dir = os.path.join(app.confdir, ".build")
325
326
327
328
    if not os.path.exists(build_dir):
        os.mkdir(build_dir)

    try:
329
330
        subprocess.call(["doxygen", "--version"])
        retcode = subprocess.call(["doxygen"], cwd=app.confdir)
331
332
333
334
335
336
337
338
339
        if retcode < 0:
            sys.stderr.write("doxygen error code: {}\n".format(-retcode))
    except OSError as e:
        sys.stderr.write("doxygen execution failed: {}\n".format(e))


def setup(app):
    """Add hook for building doxygen xml when needed"""
    app.connect("builder-inited", generate_doxygen_xml)