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