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 37# Little copy-and-paste button by code blocks, from sphinx_copybutton package 38# https://sphinx-copybutton.readthedocs.io/en/latest/ 39copybutton_prompt_text = r"[>]{1,3}" 40copybutton_prompt_is_regexp = True 41 42with open(os.path.join('..', 'include', 'petscversion.h'),'r') as version_file: 43 buf = version_file.read() 44 petsc_release_flag = re.search(' PETSC_VERSION_RELEASE[ ]*([0-9]*)',buf).group(1) 45 major_version = re.search(' PETSC_VERSION_MAJOR[ ]*([0-9]*)',buf).group(1) 46 minor_version = re.search(' PETSC_VERSION_MINOR[ ]*([0-9]*)',buf).group(1) 47 subminor_version = re.search(' PETSC_VERSION_SUBMINOR[ ]*([0-9]*)',buf).group(1) 48 patch_version = re.search(' PETSC_VERSION_PATCH[ ]*([0-9]*)',buf).group(1) 49 50 if petsc_release_flag == '0': 51 version = subprocess.check_output(['git', 'describe', '--always']).strip().decode('utf-8') 52 release = version 53 else: 54 version = '.'.join([major_version, minor_version]) 55 release = '.'.join([major_version,minor_version,subminor_version]) 56 57# -- General configuration --------------------------------------------------- 58 59extensions = [ 60 'sphinx_copybutton', 61 'sphinxcontrib.bibtex', 62 'sphinxcontrib.katex', 63 'sphinxcontrib.rsvgconverter', 64 'html5_petsc', 65] 66 67master_doc = 'index' 68# Add any paths that contain templates here, relative to this directory. 69templates_path = ['_templates'] 70 71# List of patterns, relative to source directory, that match files and 72# directories to ignore when looking for source files. 73# This pattern also affects html_static_path and html_extra_path. 74exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 75 76 77# -- Options for HTML output ------------------------------------------------- 78 79html_theme = 'pydata_sphinx_theme' 80 81html_theme_options = { 82 "icon_links": [ 83 { 84 "name": "GitLab", 85 "url": "https://gitlab.com/petsc/petsc", 86 "icon": "fab fa-gitlab", 87 }, 88 ], 89 "use_edit_page_button": True, 90} 91 92# The theme uses "github" here, but it works for GitLab 93html_context = { 94 "github_url": "https://gitlab.com", 95 "github_user": "petsc", 96 "github_repo": "petsc", 97 "github_version": "main", 98 "doc_path": "doc", 99} 100 101# Add any paths that contain custom static files (such as style sheets) here, 102# relative to this directory. They are copied after the builtin static files, 103# so a file named "default.css" will overwrite the builtin "default.css". 104html_static_path = ['_static'] 105 106html_logo = os.path.join('..', 'src', 'docs', 'website','images','PETSc-TAO_RGB.svg') 107html_favicon = os.path.join('..', 'src', 'docs', 'website','images','PETSc_RGB-logo.png') 108 109# Extra preprocessing for included "classic" docs 110import build_classic_docs 111html_extra_dir = build_classic_docs.main() 112 113# Additional files that are simply copied over with an HTML build 114html_extra_path = [html_extra_dir] 115 116# -- Options for LaTeX output -------------------------------------------- 117 118bibtex_bibfiles = [ 119 os.path.join('..', 'src', 'docs', 'tex', 'petsc.bib'), 120 os.path.join('..', 'src', 'docs', 'tex', 'petscapp.bib'), 121 ] 122latex_engine = 'xelatex' 123 124# Specify how to arrange the documents into LaTeX files. 125# This allows building only the manual. 126latex_documents = [ 127 ('manual/index', 'manual.tex', 'PETSc Users Manual', author, 'manual', False) 128 ] 129 130latex_additional_files = [ 131 'manual/anl_tech_report/ArgonneLogo.pdf', 132 'manual/anl_tech_report/ArgonneReportTemplateLastPage.pdf', 133 'manual/anl_tech_report/ArgonneReportTemplatePage2.pdf', 134 'manual/anl_tech_report/first.inc', 135 'manual/anl_tech_report/last.inc', 136] 137 138latex_elements = { 139 'maketitle': r'\newcommand{\techreportversion}{%s}' % version + 140r''' 141\input{first.inc} 142\sphinxmaketitle 143''', 144 'printindex': r''' 145\printindex 146\input{last.inc} 147''', 148 'fontpkg': r''' 149\setsansfont{DejaVu Sans} 150\setmonofont{DejaVu Sans Mono} 151''' 152} 153 154 155# -- General Config Options --------------------------------------------------- 156 157# Set default highlighting language 158highlight_language = 'c' 159autosummary_generate = True 160numfig = True 161 162# We must check what kind of builder the app uses to adjust 163def builder_init_handler(app): 164 import genteamtable 165 print("============================================") 166 print(" GENERATING TEAM TABLE FROM CONF.PY ") 167 print("============================================") 168 genDirName = "generated" 169 cwdPath = os.path.dirname(os.path.realpath(__file__)) 170 genDirPath = os.path.join(cwdPath, genDirName) 171 if "PETSC_GITLAB_PRIVATE_TOKEN" in os.environ: 172 token = os.environ["PETSC_GITLAB_PRIVATE_TOKEN"] 173 else: 174 token = None 175 genteamtable.main(genDirPath, token, app.builder.name) 176 return None 177 178# Supposedly the safer way to add additional css files. Setting html_css_files will 179# overwrite previous versions of the variable that some extension may have set. This will 180# add our css files in addition to it. 181def setup(app): 182 # Register the builder_init_handler to be called __after__ app.builder has been initialized 183 app.connect('builder-inited', builder_init_handler) 184 app.add_css_file('css/pop-up.css') 185 app.add_css_file('css/petsc-team-container.css') 186