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