/
conf.py
137 lines (112 loc) · 3.85 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
import os
import re
import subprocess
import sys
from datetime import date
from pathlib import Path
from docutils import nodes
from sphinx import addnodes
import tox
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.extlinks",
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"sphinxcontrib.autoprogram",
]
ROOT_SRC_TREE_DIR = Path(__file__).parents[1]
def generate_draft_news():
home = "https://github.com"
issue = "{}/issue".format(home)
fragments_path = ROOT_SRC_TREE_DIR / "docs" / "changelog"
for pattern, replacement in (
(r"[^`]@([^,\s]+)", r"`@\1 <{}/\1>`_".format(home)),
(r"[^`]#([\d]+)", r"`#pr\1 <{}/\1>`_".format(issue)),
):
for path in fragments_path.glob("*.rst"):
path.write_text(re.sub(pattern, replacement, path.read_text()))
env = os.environ.copy()
env["PATH"] += os.pathsep.join(
[os.path.dirname(sys.executable)] + env["PATH"].split(os.pathsep),
)
changelog = subprocess.check_output(
["towncrier", "--draft", "--version", "DRAFT"],
cwd=str(ROOT_SRC_TREE_DIR),
env=env,
).decode("utf-8")
if "No significant changes" in changelog:
content = ""
else:
note = "*Changes in master, but not released yet are under the draft section*."
content = "{}\n\n{}".format(note, changelog)
(ROOT_SRC_TREE_DIR / "docs" / "_draft.rst").write_text(content)
generate_draft_news()
project = u"tox"
_full_version = tox.__version__
release = _full_version.split("+", 1)[0]
version = ".".join(release.split(".")[:2])
author = "holger krekel and others"
year = date.today().year
copyright = u"2010-{}, {}".format(year, author)
master_doc = "index"
source_suffix = ".rst"
exclude_patterns = ["changelog/*"]
templates_path = ["_templates"]
pygments_style = "sphinx"
html_theme = "alabaster"
html_theme_options = {
"logo": "img/tox.png",
"github_user": "tox-dev",
"github_repo": "tox",
"description": "standardise testing in Python",
"github_banner": "true",
"github_type": "star",
"travis_button": "false",
"badge_branch": "master",
"fixed_sidebar": "false",
}
html_sidebars = {
"**": ["about.html", "localtoc.html", "relations.html", "searchbox.html", "donate.html"],
}
html_show_sourcelink = False
html_static_path = ["_static"]
htmlhelp_basename = "{}doc".format(project)
latex_documents = [("index", "tox.tex", u"{} Documentation".format(project), author, "manual")]
man_pages = [("index", project, u"{} Documentation".format(project), [author], 1)]
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright
suppress_warnings = ["epub.unknown_project_files"] # Prevent barking at `.ico`
intersphinx_mapping = {"https://docs.python.org/": None}
def setup(app):
def parse_node(env, text, node):
args = text.split("^")
name = args[0].strip()
node += addnodes.literal_strong(name, name)
if len(args) > 2:
default = "={}".format(args[2].strip())
node += nodes.literal(text=default)
if len(args) > 1:
content = "({})".format(args[1].strip())
node += addnodes.compact_paragraph(text=content)
return name # this will be the link
app.add_object_type(
directivename="conf",
rolename="conf",
objname="configuration value",
indextemplate="pair: %s; configuration value",
parse_node=parse_node,
)
tls_cacerts = os.getenv("SSL_CERT_FILE") # we don't care here about the validity of certificates
linkcheck_timeout = 30
linkcheck_ignore = [r"https://holgerkrekel.net"]
extlinks = {
"issue": ("https://github.com/tox-dev/tox/issues/%s", "#"),
"pull": ("https://github.com/tox-dev/tox/pull/%s", "p"),
"user": ("https://github.com/%s", "@"),
}
nitpicky = True
nitpick_ignore = [
("py:class", "tox.interpreters.InterpreterInfo"),
]