Skip to content

Commit

Permalink
Restore changes to conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kwankyu committed Apr 29, 2022
1 parent a72a8e3 commit 2535a91
Showing 1 changed file with 42 additions and 26 deletions.
68 changes: 42 additions & 26 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
r"""
Sphinx configurations
"""

import sys
import os
import sphinx
from sage.env import SAGE_DOC_SRC, SAGE_DOC, SAGE_SRC, THEBE_DIR, PPLPY_DOCS, MATHJAX_DIR
from sage.env import SAGE_DOC_SRC, SAGE_DOC, THEBE_DIR, PPLPY_DOCS, MATHJAX_DIR
from sage.misc.latex_macros import sage_mathjax_macros
import sage.version
from sage.misc.sagedoc import extlinks
import dateutil.parser
Expand All @@ -16,19 +13,23 @@
import sphinx.ext.intersphinx as intersphinx
from IPython.lib.lexers import IPythonConsoleLexer, IPyLexer


# General configuration
# ---------------------

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sage_docbuild.ext.inventory_builder',
'sage_docbuild.ext.multidocs',
'sage_docbuild.ext.sage_autodoc',
'sphinx.ext.todo',
'sphinx.ext.extlinks',
'IPython.sphinxext.ipython_directive',
'matplotlib.sphinxext.plot_directive',
'jupyter_sphinx']
extensions = [
'sage_docbuild.ext.inventory_builder',
'sage_docbuild.ext.multidocs',
'sage_docbuild.ext.sage_autodoc',
'sphinx.ext.todo',
'sphinx.ext.extlinks',
'sphinx.ext.mathjax',
'IPython.sphinxext.ipython_directive',
'matplotlib.sphinxext.plot_directive',
'jupyter_sphinx',
]

jupyter_execute_default_kernel = 'sagemath'

Expand Down Expand Up @@ -264,21 +265,36 @@ def set_intersphinx_mappings(app, config):
html_common_static_path = [os.path.join(SAGE_DOC_SRC, 'common', 'static'),
THEBE_DIR, 'static']

# We use MathJax to build the documentation.
extensions.append('sphinx.ext.mathjax')
mathjax_path = 'MathJax.js?config=TeX-AMS_HTML-full,../mathjax_sage.js'

from sage.misc.latex_macros import sage_mathjax_macros
html_theme_options['mathjax_macros'] = sage_mathjax_macros()
# Configure MathJax
# https://docs.mathjax.org/en/latest/options/input/tex.html
mathjax3_config = {
"tex": {
# Add custom sage macros
# http://docs.mathjax.org/en/latest/input/tex/macros.html
"macros": sage_mathjax_macros(),
# Add $...$ as possible inline math
# https://docs.mathjax.org/en/latest/input/tex/delimiters.html#tex-and-latex-math-delimiters
"inlineMath": [["$", "$"], ["\\(", "\\)"]],
# Increase the limit the size of the string to be processed
# https://docs.mathjax.org/en/latest/options/input/tex.html#option-descriptions
"maxBuffer": 50 * 1024,
# Use colorv2 extension instead of built-in color extension
# https://docs.mathjax.org/en/latest/input/tex/extensions/autoload.html#tex-autoload-options
# https://docs.mathjax.org/en/latest/input/tex/extensions/colorv2.html#tex-colorv2
"autoload": {"color": [], "colorv2": ["color"]},
},
}

mathjax_relative = os.path.basename(MATHJAX_DIR)
if os.environ.get('SAGE_USE_CDNS', 'no') == 'yes':
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"
else:
mathjax_path = 'mathjax/tex-chtml.js'
html_common_static_path += [MATHJAX_DIR]

# It would be really nice if sphinx would copy the entire mathjax
# directory, (so we could have a _static/mathjax directory), rather than
# the contents of the directory
html_common_static_path.append(MATHJAX_DIR)
exclude_patterns += ['**/' + os.path.join(mathjax_relative, i)
for i in ('docs', 'README*', 'test', 'unpacked', 'LICENSE')]
# A list of glob-style patterns that should be excluded when looking for source
# files. They are matched against the source file names relative to the
# source directory, using slashes as directory separators on all platforms.
exclude_patterns = []

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down

0 comments on commit 2535a91

Please sign in to comment.