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