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' 48autosummary_generate = True 49numfig = True 50 51# -- Extensions ---------------------------------------------------------------- 52 53extensions = [ 54 'sphinx_copybutton', 55 'sphinxcontrib.bibtex', 56 'sphinxcontrib.katex', 57 'sphinxcontrib.rsvgconverter', 58 'html5_petsc', 59] 60 61copybutton_prompt_text = r"[>]{1,3}" 62copybutton_prompt_is_regexp = True 63 64bibtex_bibfiles = [ 65 os.path.join('..', 'src', 'docs', 'tex', 'petsc.bib'), 66 os.path.join('..', 'src', 'docs', 'tex', 'petscapp.bib'), 67 os.path.join('..', 'src', 'docs', 'tao_tex', 'tao.bib'), 68 os.path.join('..', 'src', 'docs', 'tao_tex', 'manual', 'mathprog.bib'), 69 ] 70 71 72# -- Options for HTML output --------------------------------------------------- 73 74html_theme = 'pydata_sphinx_theme' 75 76html_theme_options = { 77 "icon_links": [ 78 { 79 "name": "GitLab", 80 "url": "https://gitlab.com/petsc/petsc", 81 "icon": "fab fa-gitlab", 82 }, 83 ], 84 "use_edit_page_button": True, 85 "footer_items": ["copyright", "sphinx-version", "last-updated"], 86} 87 88html_context = { 89 "github_url": "https://gitlab.com", 90 "github_user": "petsc", 91 "github_repo": "petsc", 92 "github_version": "release", 93 "doc_path": "doc", 94} 95 96html_static_path = ['_static'] 97html_logo = os.path.join('..', 'src', 'docs', 'website','images','PETSc-TAO_RGB.svg') 98html_favicon = os.path.join('..', 'src', 'docs', 'website','images','PETSc_RGB-logo.png') 99html_last_updated_fmt = r'%Y-%m-%dT%H:%M:%S%z (' + git_describe_version + ')' 100 101# Extra preprocessing for included "classic" docs 102import build_classic_docs 103html_extra_dir = build_classic_docs.main() 104html_extra_path = [html_extra_dir] 105 106 107# -- Options for LaTeX output -------------------------------------------------- 108latex_engine = 'xelatex' 109 110# How to arrange the documents into LaTeX files, building only the manual. 111latex_documents = [ 112 ('documentation/manual/index', 'manual.tex', 'PETSc/TAO Users Manual', author, 'manual', False) 113 ] 114 115latex_additional_files = [ 116 'documentation/manual/anl_tech_report/ArgonneLogo.pdf', 117 'documentation/manual/anl_tech_report/ArgonneReportTemplateLastPage.pdf', 118 'documentation/manual/anl_tech_report/ArgonneReportTemplatePage2.pdf', 119 'documentation/manual/anl_tech_report/first.inc', 120 'documentation/manual/anl_tech_report/last.inc', 121] 122 123latex_elements = { 124 'maketitle': r'\newcommand{\techreportversion}{%s}' % version + 125r''' 126\input{first.inc} 127''', 128 'printindex': r''' 129\printindex 130\input{last.inc} 131''', 132 'fontpkg': r''' 133\setsansfont{DejaVu Sans} 134\setmonofont{DejaVu Sans Mono} 135''', 136 'tableofcontents' : r'' 137} 138 139 140# -- Setup and event callbacks ------------------------------------------------- 141 142def builder_init_handler(app): 143 import genteamtable 144 print("============================================") 145 print(" Generating team table from conf.py ") 146 print("============================================") 147 genDirName = "generated" 148 cwdPath = os.path.dirname(os.path.realpath(__file__)) 149 genDirPath = os.path.join(cwdPath, genDirName) 150 genteamtable.main(genDirPath, builderName = app.builder.name) 151 152def build_finished_handler(app, exception): 153 if exception is None and app.builder.name.endswith('html'): 154 from make_links_relative import make_links_relative 155 print("============================================") 156 print(" Fixing relative links from conf.py ") 157 print("============================================") 158 make_links_relative(app.outdir) 159 160def setup(app): 161 app.connect('builder-inited', builder_init_handler) 162 app.connect('build-finished', build_finished_handler) 163 app.add_css_file('css/pop-up.css') 164 app.add_css_file('css/petsc-team-container.css') 165