xref: /libCEED/doc/sphinx/source/conf.py (revision 053b7ece62eece2944cfb5cf8784290d5a667f23)
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3#
4# libCEED documentation build configuration file, created by
5# sphinx-quickstart on Tue Jan  7 18:59:28 2020.
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
16# If extensions (or modules to document with autodoc) are in another directory,
17# add these directories to sys.path here. If the directory is relative to the
18# documentation root, use os.path.abspath to make it absolute, like shown here.
19#
20# import os
21# import sys
22# sys.path.insert(0, os.path.abspath('.'))
23import glob
24import shutil
25import sys
26import breathe
27import os
28import subprocess
29from sphinxcontrib import katex
30
31# -- General configuration ------------------------------------------------
32
33# If your documentation needs a minimal Sphinx version, state it here.
34#
35# needs_sphinx = '1.0'
36
37# Add any Sphinx extension module names here, as strings. They can be
38# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
39# ones.
40extensions = [
41    "sphinxext_altair.altairplot",
42    "breathe",
43    "sphinx_design",
44    "myst_parser",
45    "sphinx_rtd_theme",
46    "sphinx.ext.autodoc",
47    "sphinx.ext.coverage",
48    "sphinx.ext.doctest",
49    "sphinx.ext.ifconfig",
50    "sphinx.ext.intersphinx",
51    "sphinx.ext.githubpages",
52    "sphinxcontrib.katex",
53    "sphinxcontrib.mermaid",  # still in beta; fails with latexpdf builder
54    "sphinx.ext.todo",
55    "sphinx.ext.viewcode",
56    "sphinxcontrib.bibtex",
57    "sphinxcontrib.rsvgconverter",
58]
59
60# The following, if true, allows figures, tables and code-blocks to be
61# automatically numbered if they have a caption.
62numfig = True
63
64# Add any paths that contain templates here, relative to this directory.
65templates_path = ["_templates"]
66
67# The master toctree document.
68master_doc = "index"
69
70# General information about the project.
71project = "libCEED"
72copyright = "2020, LLNL, University of Colorado, University of Illinois, University of Tennesee, and the authors"
73with open("../../../AUTHORS") as f:
74    authorlist = f.readlines()
75author = ", ".join(authorlist)
76
77# The version info for the project you're documenting, acts as replacement for
78# |version| and |release|, also used in various other places throughout the
79# built documents.
80#
81# The short X.Y version.
82with open("../../../ceed.pc.template") as f:
83    pkgconf_version = "unknown"
84    for line in f:
85        if line.startswith("Version:"):
86            pkgconf_version = line.partition(": ")[2]
87            break
88version = pkgconf_version
89# The full version, including alpha/beta/rc tags.
90release = pkgconf_version
91
92# The language for content autogenerated by Sphinx. Refer to documentation
93# for a list of supported languages.
94#
95# This is also used if you do content translation via gettext catalogs.
96# Usually you set "language" from the command line for these cases.
97language = "en"
98
99# List of patterns, relative to source directory, that match files and
100# directories to ignore when looking for source files.
101# This patterns also effect to html_static_path and html_extra_path
102exclude_patterns = [
103    "examples/README.md",
104    "examples/ceed/README.md",
105    "examples/fluids/README.md",
106    "examples/nek/README.md",
107    "examples/petsc/README.md",
108    "examples/solid/README.md",
109    "examples/deal.II/README.md",
110]
111
112# The name of the Pygments (syntax highlighting) style to use.
113pygments_style = "sphinx"
114
115# If true, `todo` and `todoList` produce output, else they produce nothing.
116todo_include_todos = True
117
118# sphinxcontrib-bibtex 2.0 requires listing all bibtex files here
119bibtex_bibfiles = [
120    "references.bib",
121]
122
123myst_enable_extensions = [
124    "deflist",
125    "dollarmath",
126    "html_image",
127    "linkify",
128    "colon_fence",
129]
130
131myst_heading_anchors = 2
132myst_url_schemes = ("http", "https", "mailto")
133
134# -- Options for HTML output ----------------------------------------------
135
136# The theme to use for HTML and HTML Help pages.  See the documentation for
137# a list of builtin themes.
138#
139html_theme = "sphinx_rtd_theme"
140
141# Theme options are theme-specific and customize the look and feel of a theme
142# further.  For a list of options available for each theme, see the
143# documentation.
144#
145# html_theme_options = {}
146
147# Add any paths that contain custom static files (such as style sheets) here,
148# relative to this directory. They are copied after the builtin static files,
149# so a file named "default.css" will overwrite the builtin "default.css".
150html_static_path = ["css"]
151
152# Custom sidebar templates, must be a dictionary that maps document names
153# to template names.
154#
155# This is required for the alabaster theme
156# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
157html_sidebars = {
158    "**": [
159        "relations.html",  # needs 'show_related': True theme option to display
160        "searchbox.html",
161    ]
162}
163
164latex_macros = r"""
165\def \diff {\operatorname{d}\!}
166\def \tcolon {\!:\!}
167\def \trace {\operatorname{trace}}
168"""
169
170# Translate LaTeX macros to KaTeX and add to options for HTML builder
171katex_macros = katex.latex_defs_to_katex_macros(latex_macros)
172katex_options = "macros: {" + katex_macros + "}"
173
174# -- Options for HTMLHelp output ------------------------------------------
175
176# Output file base name for HTML help builder.
177htmlhelp_basename = "libCEEDdoc"
178
179
180# -- Options for LaTeX output ---------------------------------------------
181
182latex_engine = "lualatex"
183
184latex_elements = {
185    # The paper size ('letterpaper' or 'a4paper').
186    #
187    # 'papersize': 'letterpaper',
188    # The font size ('10pt', '11pt' or '12pt').
189    #
190    # 'pointsize': '10pt',
191    # Additional stuff for the LaTeX preamble.
192    #
193    "preamble": r"""
194\usepackage{amscd}
195\usepackage{cancel}
196\newcommand\bm[1]{\symbf{#1}}
197"""
198    + latex_macros,
199    # Latex figure (float) alignment
200    #
201    # 'figure_align': 'htbp',
202    "fontpkg": r"""
203\usepackage[math-style=ISO,bold-style=ISO]{unicode-math}
204\setmainfont{TeX Gyre Pagella}
205\setmathfont{TeX Gyre Pagella Math}
206\setsansfont{DejaVu Sans}
207\setmonofont{DejaVu Sans Mono}
208""",
209}
210
211latex_logo = "../../img/ceed-full-name-logo.PNG"
212
213latexauthorslist = r" \and ".join(authorlist)
214
215# Grouping the document tree into LaTeX files. List of tuples
216# (source start file, target name, title,
217#  author, documentclass [howto, manual, or own class]).
218latex_documents = [
219    (master_doc, "libCEED.tex", "libCEED User Manual", latexauthorslist, "howto"),
220]
221
222
223# -- Options for manual page output ---------------------------------------
224
225# One entry per manual page. List of tuples
226# (source start file, name, description, authors, manual section).
227man_pages = [(master_doc, "libceed", "libCEED User Manual", [author], 1)]
228
229
230# -- Options for Texinfo output -------------------------------------------
231
232# Grouping the document tree into Texinfo files. List of tuples
233# (source start file, target name, title, author,
234#  dir menu entry, description, category)
235texinfo_documents = [
236    (
237        master_doc,
238        "libCEED",
239        "libCEED User Manual",
240        latexauthorslist,
241        "libCEED",
242        "Efficient implementations of finite element operators.",
243        "Miscellaneous",
244    ),
245]
246
247
248# -- Options for Epub output ----------------------------------------------
249
250# Bibliographic Dublin Core info.
251epub_title = project
252epub_author = author
253epub_publisher = author
254epub_copyright = copyright
255
256# The unique identifier of the text. This can be a ISBN number
257# or the project homepage.
258#
259# epub_identifier = ''
260
261# A unique identification for the text.
262#
263# epub_uid = ''
264
265# A list of files that should not be packed into the epub file.
266epub_exclude_files = ["search.html"]
267
268
269# Example configuration for intersphinx: refer to the Python standard library.
270intersphinx_mapping = {
271    "python": ("https://docs.python.org/3", None),
272    "numpy": ("https://numpy.org/devdocs", None),
273}
274
275
276# -- Options for breathe --------------------------------------------------
277breathe_projects = {"libCEED": "../../../xml"}
278breathe_default_project = "libCEED"
279breathe_build_directory = "../build/breathe"
280breathe_domain_by_extension = {"c": "c", "h": "c", "cpp": "cpp", "hpp": "cpp"}
281
282# Run Doxygen if building on Read The Docs
283rootdir = os.path.join(
284    os.path.dirname(__file__),
285    os.pardir,
286    os.pardir,
287    os.pardir)
288if os.environ.get("READTHEDOCS"):
289    subprocess.check_call(["doxygen", "Doxyfile"], cwd=rootdir)
290
291
292def mkdir_p(path):
293    try:
294        os.makedirs(path)
295    except FileExistsError:
296        pass
297
298
299# Copy example documentation from source tree
300try:
301    shutil.rmtree("examples")
302except FileNotFoundError:
303    pass
304for filename in glob.glob(os.path.join(
305        rootdir, "examples/**/*.md"), recursive=True):
306    destdir = os.path.dirname(os.path.relpath(filename, rootdir))
307    mkdir_p(destdir)
308    shutil.copy2(filename, destdir)
309shutil.copy2(os.path.join(rootdir, "README.md"), ".")
310
311for filename in glob.glob(os.path.join(
312        rootdir, "examples/**/*.csv"), recursive=True):
313    destdir = os.path.dirname(os.path.relpath(filename, rootdir))
314    mkdir_p(destdir)
315    shutil.copy2(filename, destdir)
316