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