Skip to content

Commit 089c9b3

Browse files
committed
Start plugin interface documentation and installer
- Add documentation for the plugin interface - Introduce the installer abstraction - Rework how we handle tox deps section, requirement and constraint files - Support for escaping comments in tox.ini configs Signed-off-by: Bernát Gábor <[email protected]>
1 parent 54e6310 commit 089c9b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2595
-1559
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ dist
1515
/docs/_draft.rst
1616
pip-wheel-metadata
1717
Dockerfile
18-
/tox_.py
18+
/toxfile.py

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
- repo: https://github.com/asottile/pyupgrade
15-
rev: v2.10.0
15+
rev: v2.11.0
1616
hooks:
1717
- id: pyupgrade
1818
args: ["--py36-plus"]
1919
exclude: "^(src/tox/util/pep517/backend.py|tests/demo_pkg_inline/build.py)$"
2020
- id: pyupgrade
2121
files: "^(src/tox/util/pep517/backend.py|tests/demo_pkg_inline/build.py)$"
2222
- repo: https://github.com/PyCQA/isort
23-
rev: 5.7.0
23+
rev: 5.8.0
2424
hooks:
2525
- id: isort
2626
- repo: https://github.com/psf/black
@@ -30,7 +30,7 @@ repos:
3030
args:
3131
- --safe
3232
- repo: https://github.com/asottile/setup-cfg-fmt
33-
rev: v1.16.0
33+
rev: v1.17.0
3434
hooks:
3535
- id: setup-cfg-fmt
3636
args:

docs/_static/custom.css

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,19 @@
33
max-width: 100%;
44
}
55

6-
#virtualenv img {
7-
margin-bottom: 6px;
8-
}
9-
10-
/* Allow table content to wrap around */
11-
.wy-table-responsive table th,
12-
.wy-table-responsive table td {
13-
/* !important because RTD has conflicting stylesheets */
14-
white-space: normal !important;
15-
padding: 8px 6px !important;
16-
}
17-
18-
.wy-table-responsive table {
19-
width: 100%;
20-
margin-left: 0 !important;
21-
}
22-
23-
.rst-content table.docutils td ol {
24-
margin-bottom: 0;
25-
}
26-
27-
.rst-content table.docutils td ul {
28-
margin-bottom: 0;
29-
}
30-
31-
.rst-content table.docutils td p {
32-
margin-bottom: 0;
33-
}
34-
35-
div[class*="highlight-"] {
36-
margin-bottom: 12px;
37-
}
38-
39-
/* Tweak whitespace on the release history page */
40-
#release-history p {
41-
margin-bottom: 0;
42-
margin-top: 0;
43-
}
44-
45-
#release-history h3 {
46-
margin-bottom: 6px;
47-
}
48-
49-
#release-history ul {
50-
margin-bottom: 12px;
6+
/* Reduce whitespace on the inline-code snippets and add softer corners */
7+
.rst-content code {
8+
padding: 2px 3px;
9+
border-radius: 3px;
5110
}
5211

53-
#release-history ul ul {
54-
margin-bottom: 0;
12+
dl {
13+
margin-bottom: 0!important;
5514
}
5615

57-
#release-history h2 {
58-
margin-bottom: 12px;
16+
dd {
17+
margin-bottom: 2px!important;
5918
}
60-
61-
/* Reduce whitespace on the inline-code snippets and add softer corners */
62-
.rst-content code {
63-
padding: 2px 3px;
64-
border-radius: 3px;
19+
.rst-content dd p {
20+
margin-bottom: 0px;
6521
}

docs/changelog.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
Release History
22
===============
3-
43
.. include:: _draft.rst
54

65
.. towncrier release notes start

docs/changelog/1926.bugfix.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Environments with a platform mismatch are no longer silently skipped,
2-
but properly reported - by :user:`jugmac00`.
1+
Environments with a platform mismatch are no longer silently skipped, but properly reported - by :user:`jugmac00`.

docs/changelog/1991.bugfix.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Requirements and constraints files handling got reimplemented, which should fix all open issues related to this area
2+
- by :user:`gaborbernat`.

docs/changelog/1991.doc.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Start documenting the plugin interface. Added :meth:`tox_register_tox_env <tox.plugin.spec.tox_register_tox_env>`,
2+
:meth:`tox_add_option <tox.plugin.spec.tox_add_option>`,
3+
:meth:`tox_add_core_config <tox.plugin.spec.tox_add_core_config>`,
4+
:meth:`tox_configure <tox.plugin.spec.tox_configure>` - by :user:`gaborbernat`.

docs/changelog/1991.feature.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Introduce the installer concept, and collect pip installation into a ``pip`` package, also attach to this
2+
the requirements file parsing which got a major rework - by :user:`gaborbernat`.

docs/conf.py

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
import subprocess
21
import sys
32
from datetime import date, datetime
43
from pathlib import Path
4+
from subprocess import check_output
5+
from typing import Any, Optional, Tuple, Union
56

67
import sphinx_rtd_theme
8+
from docutils.nodes import Element
9+
from sphinx.addnodes import pending_xref
10+
from sphinx.application import Sphinx
11+
from sphinx.builders import Builder
12+
from sphinx.environment import BuildEnvironment
13+
from sphinx.ext.autodoc import Options
714

815
from tox.version import __version__
916

@@ -17,7 +24,11 @@
1724
"sphinx.ext.autodoc",
1825
"sphinx.ext.autosectionlabel",
1926
"sphinx.ext.extlinks",
27+
"sphinx.ext.intersphinx",
2028
"sphinx_argparse_cli",
29+
"sphinx_autodoc_typehints",
30+
"sphinx_inline_tabs",
31+
"sphinx_copybutton",
2132
]
2233

2334
templates_path = []
@@ -27,7 +38,7 @@
2738

2839
master_doc = "index"
2940
pygments_style = "default"
30-
always_document_param_types = True
41+
3142
project = name
3243
today_fmt = "%B %d, %Y"
3344

@@ -48,8 +59,17 @@
4859
html_logo = "_static/img/tox.svg"
4960
html_favicon = "_static/img/toxfavi.ico"
5061
htmlhelp_basename = "Pastedoc"
51-
autoclass_content = "both" # Include __init__ in class documentation
62+
63+
autoclass_content = "class"
5264
autodoc_member_order = "bysource"
65+
autodoc_default_options = {
66+
"member-order": "bysource",
67+
"undoc-members": True,
68+
"show-inheritance": True,
69+
}
70+
autodoc_typehints = "none"
71+
always_document_param_types = False
72+
typehints_fully_qualified = True
5373
autosectionlabel_prefix_document = True
5474

5575
extlinks = {
@@ -58,24 +78,61 @@
5878
"user": ("https://github.com/%s", "@"),
5979
"pypi": ("https://pypi.org/project/%s", ""),
6080
}
81+
intersphinx_mapping = {
82+
"python": ("https://docs.python.org/3", None),
83+
"packaging": ("https://packaging.pypa.io/en/latest", None),
84+
}
85+
nitpicky = True
86+
nitpick_ignore = []
87+
6188

89+
def skip_member(app: Sphinx, what: str, name: str, obj: Any, would_skip: bool, options: Options) -> bool: # noqa: U100
90+
return True if name in options.get("exclude-members", set()) else would_skip
6291

63-
def generate_draft_news():
92+
93+
def process_signature(
94+
app: Sphinx, objtype: str, name: str, obj: Any, options: Options, args: str, retann: Optional[str] # noqa: U100
95+
) -> Union[None, Tuple[None, None]]:
96+
# skip-member is not checked for class level docs, so disable via signature processing
97+
return (None, None) if objtype == "class" and "__init__" in options.get("exclude-members", set()) else None
98+
99+
100+
def setup(app: Sphinx) -> None:
64101
root = Path(__file__).parents[1]
65102
exe = Path(sys.executable)
66103
towncrier = exe.with_name(f"towncrier{exe.suffix}")
67-
new = subprocess.check_output([str(towncrier), "--draft", "--version", "NEXT"], cwd=root, universal_newlines=True)
104+
new = check_output([str(towncrier), "--draft", "--version", "NEXT"], cwd=root, universal_newlines=True)
68105
(root / "docs" / "_draft.rst").write_text("" if "No significant changes" in new else new)
69106

107+
from sphinx.domains.python import PythonDomain
70108

71-
generate_draft_news()
109+
class PatchedPythonDomain(PythonDomain):
110+
def resolve_xref(
111+
self,
112+
env: BuildEnvironment,
113+
fromdocname: str,
114+
builder: Builder,
115+
type: str,
116+
target: str,
117+
node: pending_xref,
118+
contnode: Element,
119+
) -> Element:
120+
# fixup some wrongly resolved mappings
121+
mapping = {
122+
"_io.TextIOWrapper": "io.TextIOWrapper",
123+
"Future": "concurrent.futures.Future",
124+
"_F": "typing.TypeVar",
125+
"V": "typing.TypeVar",
126+
"T": "typing.TypeVar",
127+
"tox.config.of_type.T": "typing.TypeVar",
128+
"tox.config.loader.api.T": "typing.TypeVar",
129+
"tox.config.loader.convert.T": "typing.TypeVar",
130+
}
131+
if target in mapping:
132+
node["reftarget"] = mapping[target]
133+
return super().resolve_xref(env, fromdocname, builder, type, target, node, contnode)
72134

73-
74-
def setup(app):
135+
app.connect("autodoc-skip-member", skip_member)
136+
app.connect("autodoc-process-signature", process_signature, priority=400)
137+
app.add_domain(PatchedPythonDomain, override=True)
75138
app.add_css_file("custom.css")
76-
77-
# the CLI arguments are dynamically generated - do not cache
78-
doc_tree = Path(app.doctreedir)
79-
cli_interface_doctree = doc_tree / "cli_interface.doctree"
80-
if cli_interface_doctree.exists():
81-
cli_interface_doctree.unlink()

docs/extend.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)