1# Configuration file for the Sphinx documentation builder. 2# 3# Much of this file was generated automatically with sphinx-quickstart 4# 5# This file only contains a selection of the most common options. For a full 6# list see the documentation: 7# http://www.sphinx-doc.org/en/master/config 8 9# -- Path setup -------------------------------------------------------------- 10 11# If extensions (or modules to document with autodoc) are in another directory, 12# add these directories to sys.path here. If the directory is relative to the 13# documentation root, use os.path.abspath to make it absolute, like shown here. 14# 15import os 16import sys 17import subprocess 18import re 19import datetime 20 21sys.path.append(os.getcwd()) 22sys.path.append(os.path.abspath('./ext')) 23 24# -- Sphinx Version and Config ----------------------------------------------- 25# Sphinx will error and refuse to build if not equal to version 26needs_sphinx='3.5' 27 28# Sphinx-build fails for any broken __internal__ links. For external use make linkcheck. 29nitpicky = True 30 31# -- Project information ----------------------------------------------------- 32 33project = 'PETSc' 34copyright = '1991-%d, UChicago Argonne, LLC and the PETSc Development Team' % datetime.date.today().year 35author = 'The PETSc Development Team' 36 37with open(os.path.join('..', 'include', 'petscversion.h'),'r') as version_file: 38 buf = version_file.read() 39 petsc_release_flag = re.search(' PETSC_VERSION_RELEASE[ ]*([0-9]*)',buf).group(1) 40 major_version = re.search(' PETSC_VERSION_MAJOR[ ]*([0-9]*)',buf).group(1) 41 minor_version = re.search(' PETSC_VERSION_MINOR[ ]*([0-9]*)',buf).group(1) 42 subminor_version = re.search(' PETSC_VERSION_SUBMINOR[ ]*([0-9]*)',buf).group(1) 43 patch_version = re.search(' PETSC_VERSION_PATCH[ ]*([0-9]*)',buf).group(1) 44 45 46 git_describe_version = subprocess.check_output(['git', 'describe', '--always']).strip().decode('utf-8') 47 if petsc_release_flag == '0': 48 version = git_describe_version 49 release = git_describe_version 50 else: 51 version = '.'.join([major_version, minor_version]) 52 release = '.'.join([major_version,minor_version,subminor_version]) 53 54# -- General configuration --------------------------------------------------- 55 56master_doc = 'index' 57# Add any paths that contain templates here, relative to this directory. 58templates_path = ['_templates'] 59 60# List of patterns, relative to source directory, that match files and 61# directories to ignore when looking for source files. 62# This pattern also affects html_static_path and html_extra_path. 63exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 64 65 66# -- Extensions -------------------------------------------------------------- 67extensions = [ 68 'sphinx_copybutton', 69 'sphinxcontrib.bibtex', 70 'sphinxcontrib.katex', 71 'sphinxcontrib.rsvgconverter', 72 'html5_petsc', 73] 74 75copybutton_prompt_text = r"[>]{1,3}" 76copybutton_prompt_is_regexp = True 77 78bibtex_bibfiles = [ 79 os.path.join('..', 'src', 'docs', 'tex', 'petsc.bib'), 80 os.path.join('..', 'src', 'docs', 'tex', 'petscapp.bib'), 81 os.path.join('..', 'src', 'docs', 'tao_tex', 'tao.bib'), 82 os.path.join('..', 'src', 'docs', 'tao_tex', 'manual', 'mathprog.bib'), 83 ] 84 85# -- Options for HTML output ------------------------------------------------- 86 87html_theme = 'pydata_sphinx_theme' 88 89html_theme_options = { 90 "icon_links": [ 91 { 92 "name": "GitLab", 93 "url": "https://gitlab.com/petsc/petsc", 94 "icon": "fab fa-gitlab", 95 }, 96 ], 97 "use_edit_page_button": True, 98 "footer_items": ["copyright", "sphinx-version", "last-updated"], 99} 100 101# The theme uses "github" here, but it works for GitLab 102html_context = { 103 "github_url": "https://gitlab.com", 104 "github_user": "petsc", 105 "github_repo": "petsc", 106 "github_version": "release", 107 "doc_path": "doc", 108} 109 110# Add any paths that contain custom static files (such as style sheets) here, 111# relative to this directory. They are copied after the builtin static files, 112# so a file named "default.css" will overwrite the builtin "default.css". 113html_static_path = ['_static'] 114 115html_logo = os.path.join('..', 'src', 'docs', 'website','images','PETSc-TAO_RGB.svg') 116html_favicon = os.path.join('..', 'src', 'docs', 'website','images','PETSc_RGB-logo.png') 117 118# Extra preprocessing for included "classic" docs 119import build_classic_docs 120html_extra_dir = build_classic_docs.main() 121 122# Additional files that are simply copied over with an HTML build 123html_extra_path = [html_extra_dir] 124 125html_last_updated_fmt = r'%Y-%m-%dT%H:%M:%S%z (' + git_describe_version + ')' 126 127# -- Options for LaTeX output -------------------------------------------- 128 129latex_engine = 'xelatex' 130 131# Specify how to arrange the documents into LaTeX files. 132# This allows building only the manual. 133latex_documents = [ 134 ('documentation/manual/index', 'manual.tex', 'PETSc/TAO Users Manual', author, 'manual', False) 135 ] 136 137latex_additional_files = [ 138 'documentation/manual/anl_tech_report/ArgonneLogo.pdf', 139 'documentation/manual/anl_tech_report/ArgonneReportTemplateLastPage.pdf', 140 'documentation/manual/anl_tech_report/ArgonneReportTemplatePage2.pdf', 141 'documentation/manual/anl_tech_report/first.inc', 142 'documentation/manual/anl_tech_report/last.inc', 143] 144 145latex_elements = { 146 'maketitle': r'\newcommand{\techreportversion}{%s}' % version + 147r''' 148\input{first.inc} 149''', 150 'printindex': r''' 151\printindex 152\input{last.inc} 153''', 154 'fontpkg': r''' 155\setsansfont{DejaVu Sans} 156\setmonofont{DejaVu Sans Mono} 157''', 158 'tableofcontents' : r'' 159} 160 161 162# -- General Config Options --------------------------------------------------- 163 164# Set default highlighting language 165highlight_language = 'c' 166autosummary_generate = True 167numfig = True 168 169# -- Setup and Event Callbacks ------------------------------------------------ 170 171# We must check what kind of builder the app uses to adjust 172def builder_init_handler(app): 173 import genteamtable 174 print("============================================") 175 print(" GENERATING TEAM TABLE FROM CONF.PY ") 176 print("============================================") 177 genDirName = "generated" 178 cwdPath = os.path.dirname(os.path.realpath(__file__)) 179 genDirPath = os.path.join(cwdPath, genDirName) 180 genteamtable.main(genDirPath, builderName = app.builder.name) 181 return None 182 183def build_finished_handler(app, exception): 184 if exception is None and app.builder.name.endswith('html'): 185 from make_links_relative import make_links_relative 186 print("============================================") 187 print(" Fixing relative links from conf.py ") 188 print("============================================") 189 make_links_relative(app.outdir) 190 191# Supposedly the safer way to add additional css files. Setting html_css_files will 192# overwrite previous versions of the variable that some extension may have set. This will 193# add our css files in addition to it. 194def setup(app): 195 # Register the builder_init_handler to be called __after__ app.builder has been initialized 196 app.connect('builder-inited', builder_init_handler) 197 app.connect('build-finished', build_finished_handler) 198 app.add_css_file('css/pop-up.css') 199 app.add_css_file('css/petsc-team-container.css') 200