|
- # Configuration file for the Sphinx documentation builder.
- #
- # This file only contains a selection of the most common options. For a full
- # list see the documentation:
- # https://www.sphinx-doc.org/en/master/usage/configuration.html
-
- # -- Path setup --------------------------------------------------------------
-
- # If extensions (or modules to document with autodoc) are in another directory,
- # add these directories to sys.path here. If the directory is relative to the
- # documentation root, use os.path.abspath to make it absolute, like shown here.
- #
- import os
- import shutil
- import IPython
- import re
- import sys
-
- # Fix mathjax tags
- from sphinx.ext import mathjax as sphinx_mathjax
-
- with open(sphinx_mathjax.__file__, "r", encoding="utf-8") as f:
- code_str = f.read()
- old_str = r''' if r'\\' in part:
- self.body.append(r'\begin{split}' + part + r'\end{split}')'''
- new_str = r''' if r'\\' in part:
- if r'\tag{' in part:
- part1, part2 = part.split(r'\tag{')
- self.body.append(r'\begin{split}' + part1 + r'\end{split}' + r'\tag{' +part2)
- else:
- self.body.append(r'\begin{split}' + part + r'\end{split}')'''
- code_str = code_str.replace(old_str, new_str)
- exec(code_str, sphinx_mathjax.__dict__)
-
- # -- Project information -----------------------------------------------------
-
- project = 'MindSpore'
- copyright = 'MindSpore'
- author = 'MindSpore'
-
- # The full version, including alpha/beta/rc tags
- release = 'master'
-
-
- # -- 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.
- myst_enable_extensions = ["dollarmath", "amsmath"]
-
-
- myst_heading_anchors = 4
- extensions = [
- 'myst_parser',
- 'nbsphinx',
- 'sphinx.ext.mathjax',
- 'IPython.sphinxext.ipython_console_highlighting'
- ]
-
- source_suffix = {
- '.rst': 'restructuredtext',
- '.md': 'markdown',
- }
-
- # Add any paths that contain templates here, relative to this directory.
- templates_path = ['_templates']
-
- # List of patterns, relative to source directory, that match files and
- # directories to ignore when looking for source files.
- # This pattern also affects html_static_path and html_extra_path.
- mathjax_path = 'https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/mathjax/MathJax-3.2.2/es5/tex-mml-chtml.js'
-
- mathjax_options = {
- 'async':'async'
- }
-
- nbsphinx_requirejs_path = 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js'
-
- nbsphinx_requirejs_options = {
- "crossorigin": "anonymous",
- "integrity": "sha256-1fEPhSsRKlFKGfK3eO710tEweHh1fwokU5wFGDHO+vg="
- }
-
- exclude_patterns = []
-
- highlight_language = 'python'
-
- pygments_style = 'sphinx'
-
- # -- Options for HTML output -------------------------------------------------
-
- # The theme to use for HTML and HTML Help pages. See the documentation for
- # a list of builtin themes.
- #
- html_theme = 'sphinx_rtd_theme'
- #modify layout.html for sphinx_rtd_theme.
- import sphinx_rtd_theme
- layout_target = os.path.join(os.path.dirname(sphinx_rtd_theme.__file__), 'layout.html')
- layout_src = '../../resource/_static/layout.html'
- if os.path.exists(layout_target):
- os.remove(layout_target)
- shutil.copy(layout_src, layout_target)
-
- html_search_language = 'zh'
-
- html_search_options = {'dict': '../resource/jieba.txt'}
-
- html_static_path = ['_static']
-
- sys.path.append(os.path.abspath('../../resource/sphinx_ext'))
- # import anchor_mod
- import nbsphinx_mod
-
-
- sys.path.append(os.path.abspath('../../resource/search'))
- import search_code
-
- sys.path.append(os.path.abspath('../../resource/custom_directives'))
- from custom_directives import IncludeCodeDirective
-
- def setup(app):
- app.add_directive('includecode', IncludeCodeDirective)
|