-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
conf.py
229 lines (181 loc) · 7.26 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
#
# Twisted documentation build configuration file, created by
# sphinx-quickstart on Tue Jan 14 11:31:15 2014.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import pathlib
import subprocess
import sys
from datetime import date
from pprint import pprint
import sphinx_rtd_theme
# 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.
sys.path.insert(0, os.path.abspath("./_extensions"))
sys.path.insert(0, os.path.abspath(".."))
# -- General configuration ------------------------------------------------
# See setup.cfg for the Sphinx version required to build the documentation.
# needs_sphinx is not use to avoid duplication and getting these values
# out of sync.
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.intersphinx",
"pydoctor.sphinx_ext.build_apidocs",
]
try:
import rst2pdf.pdfbuilder
extensions.append("rst2pdf.pdfbuilder")
except ImportError:
pass
from twisted import version as twisted_version_object
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The suffix of source filenames.
source_suffix = ".rst"
# The encoding of source files.
# source_encoding = 'utf-8-sig'
# The master toctree document.
master_doc = "index"
_today = date.today()
# General information about the project.
project = "Twisted"
copyright = "{}, Twisted Matrix Labs. Ver {}. Built on {}".format(
_today.year,
twisted_version_object.public(),
_today.isoformat(),
)
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = "{major}.{minor}".format(
major=twisted_version_object.major, minor=twisted_version_object.minor
)
# The full version, including alpha/beta/rc tags.
release = twisted_version_object.short()
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
# today = ''
# Else, today_fmt is used as the format for a strftime call.
# today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ["_build"]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = "sphinx"
# -- Options for HTML output ----------------------------------------------
# Only the RTD theme is used. Both for local development and for the public site.
html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_js_files = [
"js/custom.js",
# Here we have a Sphinx HTML injection hack to make the JS script load without blocking.
'https://sidecar.gitter.im/dist/sidecar.v1.js" defer hack="',
]
# Output file base name for HTML help builder.
htmlhelp_basename = "Twisteddoc"
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
("index", "Twisted.tex", "Twisted Documentation", "Twisted Matrix Labs", "manual"),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [("index", "twisted", "Twisted Documentation", ["Twisted Matrix Labs"], 1)]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
"index",
"Twisted",
"Twisted Documentation",
"Twisted Matrix Labs",
"Twisted",
"One line description of project.",
"Miscellaneous",
),
]
# -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info.
epub_title = "Twisted"
epub_author = "Twisted Matrix Labs"
epub_publisher = "Twisted Matrix Labs"
epub_copyright = "2020, Twisted Matrix Labs"
# -- Extension configuration ----------------------------------------------
_git_reference = subprocess.run(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
text=True,
encoding="utf8",
capture_output=True,
check=True,
).stdout
print(f"== Environment dump for {_git_reference} ===")
pprint(dict(os.environ))
print("======")
# Try to find URL fragment for the GitHub source page based on current
# branch or tag.
if _git_reference == "HEAD":
# It looks like the branch has no name.
# Fallback to commit ID.
_git_reference = subprocess.getoutput("git rev-parse HEAD")
if os.environ.get("READTHEDOCS", "") == "True":
rtd_version = os.environ.get("READTHEDOCS_VERSION", "")
if "." in rtd_version:
# It looks like we have a tag build.
_git_reference = rtd_version
_project_root = pathlib.Path(__file__).parent.parent
_source_root = _project_root / "src"
pydoctor_args = [
"--quiet",
# pydoctor should not fail the sphinx build, we have another tox environment for that.
f"--config={_project_root}/setup.cfg",
f"--html-viewsource-base=https://github.com/twisted/twisted/tree/{_git_reference}/src",
f"--project-base-dir={_source_root}",
f"--template-dir={_source_root}/twisted/python/_pydoctortemplates",
"--html-output={outdir}/api",
str(_source_root / "twisted"),
]
pydoctor_url_path = "/en/{rtd_version}/api/"
# A dict mapping unique IDs (which can be used to disambiguate references) to a
# tuple of (<external sphinx documentation URI>, <inventory file location>).
# The inventory file may be None to use the default location at the given URI.
intersphinx_mapping = {
"py3": ("https://docs.python.org/3", None),
"zopeinterface": ("https://zopeinterface.readthedocs.io/en/latest", None),
}
# How long to cache remote inventories. Positive is a number of days,
# negative means infinite. The default is 5 days, which should be fine
# for standard library documentation that does not typically change
# significantly after release.
# intersphinx_cache_limit = 5