1# Configuration file for the Sphinx documentation builder. 2# 3# For information on options, see 4# http://www.sphinx-doc.org/en/master/config 5# 6# You may also find it helpful to run "sphinx-quickstart" in a scratch 7# directory and read the comments in the automatically-generate conf.py file. 8 9import os 10import sys 11import subprocess 12import re 13import datetime 14 15sys.path.append(os.getcwd()) 16sys.path.append(os.path.abspath('./ext')) 17 18# -- Project information ------------------------------------------------------- 19 20project = 'PETSc' 21copyright = '1991-%d, UChicago Argonne, LLC and the PETSc Development Team' % datetime.date.today().year 22author = 'The PETSc Development Team' 23 24with open(os.path.join('..', 'include', 'petscversion.h'),'r') as version_file: 25 buf = version_file.read() 26 petsc_release_flag = re.search(' PETSC_VERSION_RELEASE[ ]*([0-9]*)',buf).group(1) 27 major_version = re.search(' PETSC_VERSION_MAJOR[ ]*([0-9]*)',buf).group(1) 28 minor_version = re.search(' PETSC_VERSION_MINOR[ ]*([0-9]*)',buf).group(1) 29 subminor_version = re.search(' PETSC_VERSION_SUBMINOR[ ]*([0-9]*)',buf).group(1) 30 31 git_describe_version = subprocess.check_output(['git', 'describe', '--always']).strip().decode('utf-8') 32 if petsc_release_flag == '0': 33 version = git_describe_version 34 release = git_describe_version 35 else: 36 version = '.'.join([major_version, minor_version]) 37 release = '.'.join([major_version,minor_version,subminor_version]) 38 39 40# -- General configuration ----------------------------------------------------- 41 42needs_sphinx='3.5' 43nitpicky = True # checks internal links. For external links, use "make linkcheck" 44master_doc = 'index' 45templates_path = ['_templates'] 46exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 47highlight_language = 'c' 48numfig = True 49 50# -- Extensions ---------------------------------------------------------------- 51 52extensions = [ 53 'sphinx_copybutton', 54 'sphinxcontrib.bibtex', 55 'sphinxcontrib.katex', 56 'sphinxcontrib.rsvgconverter', 57 'html5_petsc', 58] 59 60copybutton_prompt_text = r"[>]{1,3}" 61copybutton_prompt_is_regexp = True 62 63bibtex_bibfiles = [ 64 os.path.join('..', 'src', 'docs', 'tex', 'petsc.bib'), 65 os.path.join('..', 'src', 'docs', 'tex', 'petscapp.bib'), 66 os.path.join('..', 'src', 'docs', 'tao_tex', 'tao.bib'), 67 os.path.join('..', 'src', 'docs', 'tao_tex', 'manual', 'mathprog.bib'), 68 ] 69 70 71# -- Options for HTML output --------------------------------------------------- 72 73html_theme = 'pydata_sphinx_theme' 74 75html_theme_options = { 76 "icon_links": [ 77 { 78 "name": "GitLab", 79 "url": "https://gitlab.com/petsc/petsc", 80 "icon": "fab fa-gitlab", 81 }, 82 ], 83 "use_edit_page_button": True, 84 "footer_items": ["copyright", "sphinx-version", "last-updated"], 85} 86 87html_context = { 88 "github_url": "https://gitlab.com", 89 "github_user": "petsc", 90 "github_repo": "petsc", 91 "github_version": "release", 92 "doc_path": "doc", 93} 94 95html_static_path = ['_static'] 96html_logo = os.path.join('..', 'src', 'docs', 'website','images','PETSc-TAO_RGB.svg') 97html_favicon = os.path.join('..', 'src', 'docs', 'website','images','PETSc_RGB-logo.png') 98html_last_updated_fmt = r'%Y-%m-%dT%H:%M:%S%z (' + git_describe_version + ')' 99 100# Extra preprocessing for included "classic" docs 101import build_classic_docs 102html_extra_dir = build_classic_docs.main() 103html_extra_path = [html_extra_dir] 104 105 106# -- Options for LaTeX output -------------------------------------------------- 107latex_engine = 'xelatex' 108 109# How to arrange the documents into LaTeX files, building only the manual. 110latex_documents = [ 111 ('documentation/manual/index', 'manual.tex', 'PETSc/TAO Users Manual', author, 'manual', False) 112 ] 113 114latex_additional_files = [ 115 'documentation/manual/anl_tech_report/ArgonneLogo.pdf', 116 'documentation/manual/anl_tech_report/ArgonneReportTemplateLastPage.pdf', 117 'documentation/manual/anl_tech_report/ArgonneReportTemplatePage2.pdf', 118 'documentation/manual/anl_tech_report/first.inc', 119 'documentation/manual/anl_tech_report/last.inc', 120] 121 122latex_elements = { 123 'maketitle': r'\newcommand{\techreportversion}{%s}' % version + 124r''' 125\input{first.inc} 126''', 127 'printindex': r''' 128\printindex 129\input{last.inc} 130''', 131 'fontpkg': r''' 132\setsansfont{DejaVu Sans} 133\setmonofont{DejaVu Sans Mono} 134''', 135 'tableofcontents' : r'' 136} 137 138 139# -- Setup and event callbacks ------------------------------------------------- 140 141def builder_init_handler(app): 142 import genteamtable 143 print("============================================") 144 print(" Generating team table from conf.py ") 145 print("============================================") 146 genDirName = "generated" 147 cwdPath = os.path.dirname(os.path.realpath(__file__)) 148 genDirPath = os.path.join(cwdPath, genDirName) 149 genteamtable.main(genDirPath, builderName = app.builder.name) 150 151def build_finished_handler(app, exception): 152 if exception is None and app.builder.name.endswith('html'): 153 from make_links_relative import make_links_relative 154 print("============================================") 155 print(" Fixing relative links from conf.py ") 156 print("============================================") 157 make_links_relative(app.outdir) 158 159def setup(app): 160 app.connect('builder-inited', builder_init_handler) 161 app.connect('build-finished', build_finished_handler) 162 app.add_css_file('css/pop-up.css') 163 app.add_css_file('css/petsc-team-container.css') 164