conf.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. #
  4. # pybind11 documentation build configuration file, created by
  5. # sphinx-quickstart on Sun Oct 11 19:23:48 2015.
  6. #
  7. # This file is execfile()d with the current directory set to its
  8. # containing dir.
  9. #
  10. # Note that not all possible configuration values are present in this
  11. # autogenerated file.
  12. #
  13. # All configuration values have a default; values that are commented out
  14. # serve to show the default.
  15. import sys
  16. import os
  17. import shlex
  18. import subprocess
  19. from pathlib import Path
  20. import re
  21. DIR = Path(__file__).parent.resolve()
  22. # If extensions (or modules to document with autodoc) are in another directory,
  23. # add these directories to sys.path here. If the directory is relative to the
  24. # documentation root, use os.path.abspath to make it absolute, like shown here.
  25. # sys.path.insert(0, os.path.abspath('.'))
  26. # -- General configuration ------------------------------------------------
  27. # If your documentation needs a minimal Sphinx version, state it here.
  28. # needs_sphinx = '1.0'
  29. # Add any Sphinx extension module names here, as strings. They can be
  30. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
  31. # ones.
  32. extensions = [
  33. "breathe",
  34. "sphinxcontrib.rsvgconverter",
  35. "sphinxcontrib.moderncmakedomain",
  36. ]
  37. breathe_projects = {"pybind11": ".build/doxygenxml/"}
  38. breathe_default_project = "pybind11"
  39. breathe_domain_by_extension = {"h": "cpp"}
  40. # Add any paths that contain templates here, relative to this directory.
  41. templates_path = [".templates"]
  42. # The suffix(es) of source filenames.
  43. # You can specify multiple suffix as a list of string:
  44. # source_suffix = ['.rst', '.md']
  45. source_suffix = ".rst"
  46. # The encoding of source files.
  47. # source_encoding = 'utf-8-sig'
  48. # The master toctree document.
  49. master_doc = "index"
  50. # General information about the project.
  51. project = "pybind11"
  52. copyright = "2017, Wenzel Jakob"
  53. author = "Wenzel Jakob"
  54. # The version info for the project you're documenting, acts as replacement for
  55. # |version| and |release|, also used in various other places throughout the
  56. # built documents.
  57. # Read the listed version
  58. with open("../pybind11/_version.py") as f:
  59. code = compile(f.read(), "../pybind11/_version.py", "exec")
  60. loc = {}
  61. exec(code, loc)
  62. # The full version, including alpha/beta/rc tags.
  63. version = loc["__version__"]
  64. # The language for content autogenerated by Sphinx. Refer to documentation
  65. # for a list of supported languages.
  66. #
  67. # This is also used if you do content translation via gettext catalogs.
  68. # Usually you set "language" from the command line for these cases.
  69. language = None
  70. # There are two options for replacing |today|: either, you set today to some
  71. # non-false value, then it is used:
  72. # today = ''
  73. # Else, today_fmt is used as the format for a strftime call.
  74. # today_fmt = '%B %d, %Y'
  75. # List of patterns, relative to source directory, that match files and
  76. # directories to ignore when looking for source files.
  77. exclude_patterns = [".build", "release.rst"]
  78. # The reST default role (used for this markup: `text`) to use for all
  79. # documents.
  80. default_role = "any"
  81. # If true, '()' will be appended to :func: etc. cross-reference text.
  82. # add_function_parentheses = True
  83. # If true, the current module name will be prepended to all description
  84. # unit titles (such as .. function::).
  85. # add_module_names = True
  86. # If true, sectionauthor and moduleauthor directives will be shown in the
  87. # output. They are ignored by default.
  88. # show_authors = False
  89. # The name of the Pygments (syntax highlighting) style to use.
  90. # pygments_style = 'monokai'
  91. # A list of ignored prefixes for module index sorting.
  92. # modindex_common_prefix = []
  93. # If true, keep warnings as "system message" paragraphs in the built documents.
  94. # keep_warnings = False
  95. # If true, `todo` and `todoList` produce output, else they produce nothing.
  96. todo_include_todos = False
  97. # -- Options for HTML output ----------------------------------------------
  98. # The theme to use for HTML and HTML Help pages. See the documentation for
  99. # a list of builtin themes.
  100. on_rtd = os.environ.get("READTHEDOCS", None) == "True"
  101. if not on_rtd: # only import and set the theme if we're building docs locally
  102. import sphinx_rtd_theme
  103. html_theme = "sphinx_rtd_theme"
  104. html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  105. html_context = {"css_files": ["_static/theme_overrides.css"]}
  106. else:
  107. html_context = {
  108. "css_files": [
  109. "//media.readthedocs.org/css/sphinx_rtd_theme.css",
  110. "//media.readthedocs.org/css/readthedocs-doc-embed.css",
  111. "_static/theme_overrides.css",
  112. ]
  113. }
  114. # Theme options are theme-specific and customize the look and feel of a theme
  115. # further. For a list of options available for each theme, see the
  116. # documentation.
  117. # html_theme_options = {}
  118. # Add any paths that contain custom themes here, relative to this directory.
  119. # html_theme_path = []
  120. # The name for this set of Sphinx documents. If None, it defaults to
  121. # "<project> v<version> documentation".
  122. # html_title = None
  123. # A shorter title for the navigation bar. Default is the same as html_title.
  124. # html_short_title = None
  125. # The name of an image file (relative to this directory) to place at the top
  126. # of the sidebar.
  127. # html_logo = None
  128. # The name of an image file (within the static path) to use as favicon of the
  129. # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
  130. # pixels large.
  131. # html_favicon = None
  132. # Add any paths that contain custom static files (such as style sheets) here,
  133. # relative to this directory. They are copied after the builtin static files,
  134. # so a file named "default.css" will overwrite the builtin "default.css".
  135. html_static_path = ["_static"]
  136. # Add any extra paths that contain custom files (such as robots.txt or
  137. # .htaccess) here, relative to this directory. These files are copied
  138. # directly to the root of the documentation.
  139. # html_extra_path = []
  140. # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
  141. # using the given strftime format.
  142. # html_last_updated_fmt = '%b %d, %Y'
  143. # If true, SmartyPants will be used to convert quotes and dashes to
  144. # typographically correct entities.
  145. # html_use_smartypants = True
  146. # Custom sidebar templates, maps document names to template names.
  147. # html_sidebars = {}
  148. # Additional templates that should be rendered to pages, maps page names to
  149. # template names.
  150. # html_additional_pages = {}
  151. # If false, no module index is generated.
  152. # html_domain_indices = True
  153. # If false, no index is generated.
  154. # html_use_index = True
  155. # If true, the index is split into individual pages for each letter.
  156. # html_split_index = False
  157. # If true, links to the reST sources are added to the pages.
  158. # html_show_sourcelink = True
  159. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
  160. # html_show_sphinx = True
  161. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
  162. # html_show_copyright = True
  163. # If true, an OpenSearch description file will be output, and all pages will
  164. # contain a <link> tag referring to it. The value of this option must be the
  165. # base URL from which the finished HTML is served.
  166. # html_use_opensearch = ''
  167. # This is the file name suffix for HTML files (e.g. ".xhtml").
  168. # html_file_suffix = None
  169. # Language to be used for generating the HTML full-text search index.
  170. # Sphinx supports the following languages:
  171. # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
  172. # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
  173. # html_search_language = 'en'
  174. # A dictionary with options for the search language support, empty by default.
  175. # Now only 'ja' uses this config value
  176. # html_search_options = {'type': 'default'}
  177. # The name of a javascript file (relative to the configuration directory) that
  178. # implements a search results scorer. If empty, the default will be used.
  179. # html_search_scorer = 'scorer.js'
  180. # Output file base name for HTML help builder.
  181. htmlhelp_basename = "pybind11doc"
  182. # -- Options for LaTeX output ---------------------------------------------
  183. latex_engine = "pdflatex"
  184. latex_elements = {
  185. # The paper size ('letterpaper' or 'a4paper').
  186. # 'papersize': 'letterpaper',
  187. #
  188. # The font size ('10pt', '11pt' or '12pt').
  189. # 'pointsize': '10pt',
  190. #
  191. # Additional stuff for the LaTeX preamble.
  192. # remove blank pages (between the title page and the TOC, etc.)
  193. "classoptions": ",openany,oneside",
  194. "preamble": r"""
  195. \usepackage{fontawesome}
  196. \usepackage{textgreek}
  197. \DeclareUnicodeCharacter{00A0}{}
  198. \DeclareUnicodeCharacter{2194}{\faArrowsH}
  199. \DeclareUnicodeCharacter{1F382}{\faBirthdayCake}
  200. \DeclareUnicodeCharacter{1F355}{\faAdjust}
  201. \DeclareUnicodeCharacter{0301}{'}
  202. \DeclareUnicodeCharacter{03C0}{\textpi}
  203. """,
  204. # Latex figure (float) alignment
  205. # 'figure_align': 'htbp',
  206. }
  207. # Grouping the document tree into LaTeX files. List of tuples
  208. # (source start file, target name, title,
  209. # author, documentclass [howto, manual, or own class]).
  210. latex_documents = [
  211. (master_doc, "pybind11.tex", "pybind11 Documentation", "Wenzel Jakob", "manual"),
  212. ]
  213. # The name of an image file (relative to this directory) to place at the top of
  214. # the title page.
  215. # latex_logo = 'pybind11-logo.png'
  216. # For "manual" documents, if this is true, then toplevel headings are parts,
  217. # not chapters.
  218. # latex_use_parts = False
  219. # If true, show page references after internal links.
  220. # latex_show_pagerefs = False
  221. # If true, show URL addresses after external links.
  222. # latex_show_urls = False
  223. # Documents to append as an appendix to all manuals.
  224. # latex_appendices = []
  225. # If false, no module index is generated.
  226. # latex_domain_indices = True
  227. # -- Options for manual page output ---------------------------------------
  228. # One entry per manual page. List of tuples
  229. # (source start file, name, description, authors, manual section).
  230. man_pages = [(master_doc, "pybind11", "pybind11 Documentation", [author], 1)]
  231. # If true, show URL addresses after external links.
  232. # man_show_urls = False
  233. # -- Options for Texinfo output -------------------------------------------
  234. # Grouping the document tree into Texinfo files. List of tuples
  235. # (source start file, target name, title, author,
  236. # dir menu entry, description, category)
  237. texinfo_documents = [
  238. (
  239. master_doc,
  240. "pybind11",
  241. "pybind11 Documentation",
  242. author,
  243. "pybind11",
  244. "One line description of project.",
  245. "Miscellaneous",
  246. ),
  247. ]
  248. # Documents to append as an appendix to all manuals.
  249. # texinfo_appendices = []
  250. # If false, no module index is generated.
  251. # texinfo_domain_indices = True
  252. # How to display URL addresses: 'footnote', 'no', or 'inline'.
  253. # texinfo_show_urls = 'footnote'
  254. # If true, do not generate a @detailmenu in the "Top" node's menu.
  255. # texinfo_no_detailmenu = False
  256. primary_domain = "cpp"
  257. highlight_language = "cpp"
  258. def generate_doxygen_xml(app):
  259. build_dir = os.path.join(app.confdir, ".build")
  260. if not os.path.exists(build_dir):
  261. os.mkdir(build_dir)
  262. try:
  263. subprocess.call(["doxygen", "--version"])
  264. retcode = subprocess.call(["doxygen"], cwd=app.confdir)
  265. if retcode < 0:
  266. sys.stderr.write("doxygen error code: {}\n".format(-retcode))
  267. except OSError as e:
  268. sys.stderr.write("doxygen execution failed: {}\n".format(e))
  269. def prepare(app):
  270. with open(DIR.parent / "README.rst") as f:
  271. contents = f.read()
  272. if app.builder.name == "latex":
  273. # Remove badges and stuff from start
  274. contents = contents[contents.find(r".. start") :]
  275. # Filter out section titles for index.rst for LaTeX
  276. contents = re.sub(r"^(.*)\n[-~]{3,}$", r"**\1**", contents, flags=re.MULTILINE)
  277. with open(DIR / "readme.rst", "w") as f:
  278. f.write(contents)
  279. def clean_up(app, exception):
  280. (DIR / "readme.rst").unlink()
  281. def setup(app):
  282. # Add hook for building doxygen xml when needed
  283. app.connect("builder-inited", generate_doxygen_xml)
  284. # Copy the readme in
  285. app.connect("builder-inited", prepare)
  286. # Clean up the generated readme
  287. app.connect("build-finished", clean_up)