1
# Configuration file for the Sphinx documentation builder.
3
# This file only contains a selection of the most common options. For a full
4
# list see the documentation:
5
# https://www.sphinx-doc.org/en/master/usage/configuration.html
7
# -- Path setup --------------------------------------------------------------
9
# If extensions (or modules to document with autodoc) are in another directory,
10
# add these directories to sys.path here. If the directory is relative to the
11
# documentation root, use os.path.abspath to make it absolute, like shown here.
15
# sys.path.insert(0, os.path.abspath('.'))
17
sys.path.insert(0, "../../")
19
import sphinx_rtd_theme
26
# -- Project information -----------------------------------------------------
29
author = 'THUNLP OpenDelta Team'
30
copyright = '{}, {}, Licenced under the Apache License, Version 2.0'.format(datetime.datetime.now().year, author)
33
# The full version, including alpha/beta/rc tags
37
html_theme = 'sphinx_rtd_theme'
38
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
40
doctest_default_flags = doctest.NORMALIZE_WHITESPACE
41
autodoc_member_order = 'bysource'
42
intersphinx_mapping = {'python': ('https://docs.python.org/', None),
43
"torch": ("https://pytorch.org/docs/stable/", None),}
45
html_show_sourcelink = True
47
# -- General configuration ---------------------------------------------------
49
# Add any Sphinx extension module names here, as strings. They can be
50
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
54
'sphinx.ext.autosummary',
56
'sphinx.ext.intersphinx',
57
# 'sphinx.ext.mathbase',
59
'sphinx.ext.napoleon',
60
'sphinx.ext.viewcode',
61
'sphinx.ext.githubpages',
63
'sphinx_toolbox.collapse',
67
myst_enable_extensions = [
76
'.rst': 'restructuredtext',
81
# Add any paths that contain templates here, relative to this directory.
82
templates_path = ['_templates']
84
# List of patterns, relative to source directory, that match files and
85
# directories to ignore when looking for source files.
86
# This pattern also affects html_static_path and html_extra_path.
87
# exclude_patterns = []
90
# -- Options for HTML output -------------------------------------------------
92
# The theme to use for HTML and HTML Help pages. See the documentation for
93
# a list of builtin themes.
95
# html_theme = 'alabaster'
97
# Add any paths that contain custom static files (such as style sheets) here,
98
# relative to this directory. They are copied after the builtin static files,
99
# so a file named "default.css" will overwrite the builtin "default.css".
100
html_theme_options = {
101
# 'collapse_navigation': False,
102
# 'display_version': True,
104
'navigation_depth': 2,
108
html_static_path = ['_static']
109
html_css_files = ['css/custom.css']
110
html_js_files = ['js/custom.js']
111
rst_context = {'opendelta': opendelta}
112
# rst_epilog = "\n.. include:: .special.rst\n"
113
add_module_names = False
115
def include_only_tagged(app, what, name, obj, skip, options):
116
inclusion_tag_format = "[NODOC]" #can be any pattern here, choose what works for you
117
for tag in app.tags.tags:
118
if obj.__doc__ is not None and not obj.__doc__.startswith(inclusion_tag_format):
122
def skip2(app, what, name, obj, skip, options):
130
return True if name in members else skip
132
def skip(app, what, name, obj, skip, options):
133
skip = include_only_tagged(app, what, name, obj, skip, options) or\
134
skip2(app, what, name, obj, skip, options)
141
def rst_jinja_render(app, docname, source):
143
rendered = app.builder.templates.render_string(src, rst_context)
146
app.connect('autodoc-skip-member', skip)
147
app.connect("source-read", rst_jinja_render)