OpenDelta

Форк
0
147 строк · 4.3 Кб
1
# Configuration file for the Sphinx documentation builder.
2
#
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
6

7
# -- Path setup --------------------------------------------------------------
8

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.
12
#
13
# import os
14
# import sys
15
# sys.path.insert(0, os.path.abspath('.'))
16
import sys
17
sys.path.insert(0, "../../")
18
import datetime
19
import sphinx_rtd_theme
20
import doctest
21
import opendelta
22

23

24

25

26
# -- Project information -----------------------------------------------------
27

28
project = 'OpenDelta'
29
author = 'THUNLP OpenDelta Team'
30
copyright = '{}, {}, Licenced under the Apache License, Version 2.0'.format(datetime.datetime.now().year, author)
31

32

33
# The full version, including alpha/beta/rc tags
34
release = '0.3.2'
35
version = "0.3.2"
36

37
html_theme = 'sphinx_rtd_theme'
38
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
39

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),}
44

45
html_show_sourcelink = True
46

47
# -- General configuration ---------------------------------------------------
48

49
# Add any Sphinx extension module names here, as strings. They can be
50
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
51
# ones.
52
extensions = [
53
    'sphinx.ext.autodoc',
54
    'sphinx.ext.autosummary',
55
    'sphinx.ext.doctest',
56
    'sphinx.ext.intersphinx',
57
    # 'sphinx.ext.mathbase',
58
    'sphinx.ext.mathjax',
59
    'sphinx.ext.napoleon',
60
    'sphinx.ext.viewcode',
61
    'sphinx.ext.githubpages',
62
    'sphinx_copybutton',
63
    'sphinx_toolbox.collapse',
64
    'myst_parser',
65
]
66

67
myst_enable_extensions = [
68
    "html_image", 
69
    "colon_fence", 
70
    "html_admonition",
71
    "amsmath",
72
    "dollarmath",
73
]
74

75
source_suffix = {
76
    '.rst': 'restructuredtext',
77
    '.txt': 'markdown',
78
    '.md': 'markdown',
79
}
80

81
# Add any paths that contain templates here, relative to this directory.
82
templates_path = ['_templates']
83

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 = []
88

89

90
# -- Options for HTML output -------------------------------------------------
91

92
# The theme to use for HTML and HTML Help pages.  See the documentation for
93
# a list of builtin themes.
94
#
95
# html_theme = 'alabaster'
96

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,
103
    #'logo_only': False,
104
    'navigation_depth': 2,
105
}
106

107

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
114

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):
119
            return False
120
    return True
121

122
def skip2(app, what, name, obj, skip, options):
123
        members = [
124
            '__init__',
125
            '__repr__',
126
            '__weakref__',
127
            '__dict__',
128
            '__module__',
129
        ]
130
        return True if name in members else skip
131

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)
135
    return skip
136

137
def setup(app):
138
    
139
    
140

141
    def rst_jinja_render(app, docname, source):
142
        src = source[0]
143
        rendered = app.builder.templates.render_string(src, rst_context)
144
        source[0] = rendered
145

146
    app.connect('autodoc-skip-member', skip)
147
    app.connect("source-read", rst_jinja_render)

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.