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