sphinxcontrib.external-links 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sphinxcontrib_external_links-0.1.0/LICENSE +201 -0
- sphinxcontrib_external_links-0.1.0/PKG-INFO +58 -0
- sphinxcontrib_external_links-0.1.0/README.md +27 -0
- sphinxcontrib_external_links-0.1.0/pyproject.toml +217 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/__init__.py +38 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/_case_insensitive_mapping.py +46 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/_roles.py +49 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/_transforms.py +106 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/constants.py +56 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/py.typed +0 -0
- sphinxcontrib_external_links-0.1.0/sphinxcontrib/external_links/type_defs.py +31 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2024 Kyle Finley
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sphinxcontrib.external-links
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Sphinx extension for easily adding reusable external links.
|
|
5
|
+
Home-page: https://github.com/ITProKyle/sphinxcontrib.external-links
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: documentation,extension,sphinx
|
|
8
|
+
Author: Kyle Finley
|
|
9
|
+
Author-email: kyle@finley.sh
|
|
10
|
+
Requires-Python: >=3.9,<4.0
|
|
11
|
+
Classifier: Framework :: Sphinx :: Extension
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Documentation :: Sphinx
|
|
22
|
+
Classifier: Topic :: Software Development :: Documentation
|
|
23
|
+
Requires-Dist: sphinx (>=7.2.6,<8.0.0)
|
|
24
|
+
Project-URL: Documentation, https://sphinxcontribexternal-links.readthedocs.io/
|
|
25
|
+
Project-URL: Repository, https://github.com/ITProKyle/sphinxcontrib.external-links
|
|
26
|
+
Project-URL: bugs, https://github.com/ITProKyle/sphinxcontrib.external-links/issues
|
|
27
|
+
Project-URL: changelog, https://github.com/ITProKyle/sphinxcontrib.external-links/releases
|
|
28
|
+
Project-URL: issues, https://github.com/ITProKyle/sphinxcontrib.external-links/issues
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# sphinxcontrib.external-links
|
|
32
|
+
|
|
33
|
+
Sphinx extension for easily adding reusable external links.
|
|
34
|
+
|
|
35
|
+
## Features
|
|
36
|
+
|
|
37
|
+
- default list of commonly used external links
|
|
38
|
+
- user configurable links
|
|
39
|
+
- check documentation for hardcoded links that can be replaced
|
|
40
|
+
- compatible with the Sphinx's `linkcheck` builder to check link integrity
|
|
41
|
+
- - global [substitutions](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#substitutions)
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
external_links = {
|
|
47
|
+
"Google": "https://google.com", # matches ":link:`google`", ":link:`Google`", etc
|
|
48
|
+
}
|
|
49
|
+
external_links_substitutions = {
|
|
50
|
+
"dict": ":class:`dict`",
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
```rst
|
|
55
|
+
Provide a link to :link:`Google` to :link:`google.com <google>`.
|
|
56
|
+
This thing is a |dict|.
|
|
57
|
+
```
|
|
58
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# sphinxcontrib.external-links
|
|
2
|
+
|
|
3
|
+
Sphinx extension for easily adding reusable external links.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- default list of commonly used external links
|
|
8
|
+
- user configurable links
|
|
9
|
+
- check documentation for hardcoded links that can be replaced
|
|
10
|
+
- compatible with the Sphinx's `linkcheck` builder to check link integrity
|
|
11
|
+
- - global [substitutions](https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#substitutions)
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
external_links = {
|
|
17
|
+
"Google": "https://google.com", # matches ":link:`google`", ":link:`Google`", etc
|
|
18
|
+
}
|
|
19
|
+
external_links_substitutions = {
|
|
20
|
+
"dict": ":class:`dict`",
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
```rst
|
|
25
|
+
Provide a link to :link:`Google` to :link:`google.com <google>`.
|
|
26
|
+
This thing is a |dict|.
|
|
27
|
+
```
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "sphinxcontrib.external-links"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
authors = ["Kyle Finley <kyle@finley.sh>"]
|
|
5
|
+
classifiers = [
|
|
6
|
+
"Framework :: Sphinx :: Extension",
|
|
7
|
+
"Intended Audience :: Developers",
|
|
8
|
+
"Natural Language :: English",
|
|
9
|
+
"Operating System :: OS Independent",
|
|
10
|
+
"Programming Language :: Python :: 3.10",
|
|
11
|
+
"Programming Language :: Python :: 3.11",
|
|
12
|
+
"Programming Language :: Python :: 3.12",
|
|
13
|
+
"Programming Language :: Python :: 3.9",
|
|
14
|
+
"Topic :: Documentation :: Sphinx",
|
|
15
|
+
"Topic :: Software Development :: Documentation",
|
|
16
|
+
]
|
|
17
|
+
description = "Sphinx extension for easily adding reusable external links."
|
|
18
|
+
documentation = "https://sphinxcontribexternal-links.readthedocs.io/"
|
|
19
|
+
homepage = "https://github.com/ITProKyle/sphinxcontrib.external-links"
|
|
20
|
+
keywords = [
|
|
21
|
+
"documentation",
|
|
22
|
+
"extension",
|
|
23
|
+
"sphinx",
|
|
24
|
+
]
|
|
25
|
+
license = "Apache-2.0"
|
|
26
|
+
packages = [{include = "sphinxcontrib"}]
|
|
27
|
+
readme = "README.md"
|
|
28
|
+
repository = "https://github.com/ITProKyle/sphinxcontrib.external-links"
|
|
29
|
+
|
|
30
|
+
[tool.poetry.dependencies]
|
|
31
|
+
python = "^3.9"
|
|
32
|
+
sphinx = "^7.2.6"
|
|
33
|
+
|
|
34
|
+
[tool.poetry.group.dev.dependencies]
|
|
35
|
+
pre-commit = "^3.7.0"
|
|
36
|
+
|
|
37
|
+
[tool.poetry.group.docs.dependencies]
|
|
38
|
+
doc8 = "^1.1.1"
|
|
39
|
+
furo = "^2024.1.29"
|
|
40
|
+
sphinx-autobuild = "^2024.2.4"
|
|
41
|
+
sphinx-copybutton = "^0.5.2"
|
|
42
|
+
sphinx-design = "^0.5.0"
|
|
43
|
+
sphinxcontrib-jquery = "^4.1"
|
|
44
|
+
sphinxcontrib-trio = "^1.1.2"
|
|
45
|
+
|
|
46
|
+
[tool.poetry.group.lint.dependencies]
|
|
47
|
+
black = "^24.3.0"
|
|
48
|
+
ruff = "^0.3.4"
|
|
49
|
+
|
|
50
|
+
[tool.poetry.group.test.dependencies]
|
|
51
|
+
pytest = "^8.1.1"
|
|
52
|
+
pytest-cov = "^5.0.0"
|
|
53
|
+
pytest-mock = "^3.14.0"
|
|
54
|
+
pytest-sugar = ">=1.0.0"
|
|
55
|
+
pytest-xdist = {extras = ["psutil"], version = "^3.5.0"}
|
|
56
|
+
|
|
57
|
+
[tool.poetry.urls]
|
|
58
|
+
bugs = "https://github.com/ITProKyle/sphinxcontrib.external-links/issues"
|
|
59
|
+
changelog = "https://github.com/ITProKyle/sphinxcontrib.external-links/releases"
|
|
60
|
+
issues = "https://github.com/ITProKyle/sphinxcontrib.external-links/issues"
|
|
61
|
+
|
|
62
|
+
[tool.black]
|
|
63
|
+
force-exclude = '''
|
|
64
|
+
/(
|
|
65
|
+
\.eggs
|
|
66
|
+
| \.git
|
|
67
|
+
| \.venv
|
|
68
|
+
| _build
|
|
69
|
+
| build
|
|
70
|
+
| dist
|
|
71
|
+
| node_modules
|
|
72
|
+
)/
|
|
73
|
+
'''
|
|
74
|
+
include = '\.pyi?$'
|
|
75
|
+
line-length = 100
|
|
76
|
+
target-version = ["py310", "py311", "py312", "py39"]
|
|
77
|
+
|
|
78
|
+
[tool.coverage.report]
|
|
79
|
+
exclude_lines = [
|
|
80
|
+
"@overload",
|
|
81
|
+
"cov: ignore", # standard exclude comment
|
|
82
|
+
"if TYPE_CHECKING:", # excluded blocks
|
|
83
|
+
"if __name__ == .__main__.:",
|
|
84
|
+
"raise AssertionError", # defensive exceptions
|
|
85
|
+
"raise NotImplementedError",
|
|
86
|
+
]
|
|
87
|
+
fail_under = 100
|
|
88
|
+
precision = 2
|
|
89
|
+
show_missing = true
|
|
90
|
+
|
|
91
|
+
[tool.coverage.run]
|
|
92
|
+
branch = false # not correctly reported - https://github.com/nedbat/coveragepy/issues/605
|
|
93
|
+
omit = [
|
|
94
|
+
"*/type_defs.py",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[tool.doc8]
|
|
98
|
+
ignore = [
|
|
99
|
+
"D001", # Line too long
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[tool.poetry-dynamic-versioning] # poetry self add "poetry-dynamic-versioning[plugin]"
|
|
103
|
+
bump = true
|
|
104
|
+
enable = false
|
|
105
|
+
fix-shallow-repository = true
|
|
106
|
+
metadata = false
|
|
107
|
+
strict = true
|
|
108
|
+
style = "pep440"
|
|
109
|
+
|
|
110
|
+
[tool.pyright]
|
|
111
|
+
exclude = [
|
|
112
|
+
"**/.eggs",
|
|
113
|
+
"**/.git",
|
|
114
|
+
"**/.venv",
|
|
115
|
+
"**/__pycache__",
|
|
116
|
+
"**/docs",
|
|
117
|
+
"**/node_modules",
|
|
118
|
+
"**/typings",
|
|
119
|
+
]
|
|
120
|
+
pythonPlatform = "All"
|
|
121
|
+
pythonVersion = "3.9"
|
|
122
|
+
reportDuplicateImport = "none"
|
|
123
|
+
reportImportCycles = "none"
|
|
124
|
+
reportIncompatibleMethodOverride = "warning"
|
|
125
|
+
reportMissingTypeStubs = "none"
|
|
126
|
+
reportPrivateUsage = "none"
|
|
127
|
+
reportUnknownMemberType = "none"
|
|
128
|
+
reportUnnecessaryIsInstance = "warning"
|
|
129
|
+
reportUnusedImport = "none"
|
|
130
|
+
reportUnusedVariable = "none"
|
|
131
|
+
strictParameterNoneValue = false
|
|
132
|
+
typeCheckingMode = "strict"
|
|
133
|
+
useLibraryCodeForTypes = true
|
|
134
|
+
venv = ".venv"
|
|
135
|
+
|
|
136
|
+
[tool.pytest.ini_options]
|
|
137
|
+
addopts = [
|
|
138
|
+
"--cov-config=pyproject.toml",
|
|
139
|
+
]
|
|
140
|
+
filterwarnings = [
|
|
141
|
+
"ignore::pytest_mock.PytestMockWarning",
|
|
142
|
+
]
|
|
143
|
+
markers = [
|
|
144
|
+
"wip: isolate tests currently being worked on.",
|
|
145
|
+
]
|
|
146
|
+
python_classes = ["Test*"]
|
|
147
|
+
python_files = ["test_*.py"]
|
|
148
|
+
python_functions = ["test_*"]
|
|
149
|
+
testpaths = ["tests"]
|
|
150
|
+
|
|
151
|
+
[tool.ruff] # https://docs.astral.sh/ruff/settings/#top-level
|
|
152
|
+
force-exclude = true
|
|
153
|
+
line-length = 120
|
|
154
|
+
show-fixes = true
|
|
155
|
+
target-version = "py39"
|
|
156
|
+
|
|
157
|
+
[tool.ruff.lint] # https://docs.astral.sh/ruff/settings/#lint
|
|
158
|
+
ignore = [
|
|
159
|
+
"ANN101", # Missing type annotation for `self` in method
|
|
160
|
+
"ANN102", # Missing type annotation for `cls` in classmethod
|
|
161
|
+
"COM812", # Trailing comma missing
|
|
162
|
+
"D203", # 1 blank line required before class docstring
|
|
163
|
+
"D213", # Multi-line docstring summary should start at the second line
|
|
164
|
+
"D215", # Section underline is over-indented
|
|
165
|
+
"D403", # First word of the first line should be capitalized
|
|
166
|
+
"D406", # Section name should end with a newline
|
|
167
|
+
"D407", # Missing dashed underline after section
|
|
168
|
+
"D408", # Section underline should be in the line following the section's name
|
|
169
|
+
"D409", # Section underline should match the length of its name
|
|
170
|
+
"ERA001", # Found commented-out code # NOTE (kyle): incorrectly detects cspell
|
|
171
|
+
"FIX002", # Line contains TODO
|
|
172
|
+
"TD003", # Missing issue link on the line following this TODO
|
|
173
|
+
"TID252", # Relative imports from parent modules are banned
|
|
174
|
+
]
|
|
175
|
+
ignore-init-module-imports = true
|
|
176
|
+
select = ["ALL"]
|
|
177
|
+
|
|
178
|
+
[tool.ruff.lint.extend-per-file-ignores] # https://docs.astral.sh/ruff/settings/#lintextend-per-file-ignores
|
|
179
|
+
"*.py" = [
|
|
180
|
+
"PYI024", # Use `typing.NamedTuple` instead of `collections.namedtuple` - should only apply to pyi
|
|
181
|
+
]
|
|
182
|
+
"tests/*" = [
|
|
183
|
+
"FBT001", # Boolean positional arg in function definition - this is fine here
|
|
184
|
+
"FBT003", # Boolean positional value in function call - this is fine here
|
|
185
|
+
"PT004", # Fixture does not return anything, add leading underscore
|
|
186
|
+
"S101", # Use of `assert` detected - this is fine here
|
|
187
|
+
"S108", # Probable insecure usage of temporary file or directory
|
|
188
|
+
"S604", # Function call with `shell=True` parameter identified - this is fine here
|
|
189
|
+
"SLF001", # Private member accessed - fine in tests
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
[tool.ruff.lint.flake8-type-checking] # https://docs.astral.sh/ruff/settings/#lint_flake8-type-checking_runtime-evaluated-base-classes
|
|
193
|
+
runtime-evaluated-base-classes = [
|
|
194
|
+
"pydantic.BaseModel",
|
|
195
|
+
"pydantic.BeforeValidator",
|
|
196
|
+
]
|
|
197
|
+
|
|
198
|
+
[tool.ruff.lint.pydocstyle] # https://docs.astral.sh/ruff/settings/#lintpydocstyle
|
|
199
|
+
convention = "google"
|
|
200
|
+
|
|
201
|
+
[tool.ruff.lint.pylint] # https://docs.astral.sh/ruff/settings/#lintpylint
|
|
202
|
+
allow-magic-value-types = ["bytes", "int", "str"]
|
|
203
|
+
max-args = 15
|
|
204
|
+
max-returns = 10
|
|
205
|
+
|
|
206
|
+
[tool.tomlsort]
|
|
207
|
+
all = true
|
|
208
|
+
in_place = true
|
|
209
|
+
sort_first = ["tool", "tool.poetry"]
|
|
210
|
+
spaces_before_inline_comment = 2
|
|
211
|
+
trailing_comma_inline_array = true
|
|
212
|
+
overrides."tool.poetry".first = ["name", "version"]
|
|
213
|
+
overrides."tool.poetry.dependencies".first = ["python"]
|
|
214
|
+
|
|
215
|
+
[build-system]
|
|
216
|
+
build-backend = "poetry.core.masonry.api"
|
|
217
|
+
requires = ["poetry-core"]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"""Sphinx extension sphinxcontrib.external-links."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from . import constants, type_defs
|
|
9
|
+
from ._roles import links_role
|
|
10
|
+
from ._transforms import ExternalLinkChecker, GlobalSubstitutions
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from sphinx.application import Sphinx
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
__version__ = version(__name__)
|
|
17
|
+
except PackageNotFoundError: # cov: ignore
|
|
18
|
+
# package is not installed
|
|
19
|
+
__version__ = "0.0.0"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def setup_roles(app: Sphinx) -> None:
|
|
23
|
+
"""Setup roles."""
|
|
24
|
+
app.add_role("link", links_role(app.config.external_links))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def setup(app: Sphinx) -> type_defs.ExtensionMetadata:
|
|
28
|
+
"""Setup extension."""
|
|
29
|
+
app.add_config_value("external_links", default={}, rebuild="env")
|
|
30
|
+
app.add_config_value("external_links_detect_hardcoded_links", default=True, rebuild="env")
|
|
31
|
+
app.add_config_value("external_links_substitutions", default={}, rebuild="env")
|
|
32
|
+
app.add_transform(GlobalSubstitutions)
|
|
33
|
+
app.connect("builder-inited", setup_roles)
|
|
34
|
+
app.add_post_transform(ExternalLinkChecker)
|
|
35
|
+
return {"version": __version__, "parallel_read_safe": True}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
__all__ = ["constants", "type_defs"]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""case-insensitive :class:`collections.abc.Mapping`."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from collections import OrderedDict
|
|
7
|
+
from collections.abc import Mapping
|
|
8
|
+
from typing import TYPE_CHECKING
|
|
9
|
+
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from collections.abc import Generator
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CaseInsensitiveMapping(Mapping[str, str]):
|
|
15
|
+
"""A case-insensitive :class:`collections.abc.Mapping` object."""
|
|
16
|
+
|
|
17
|
+
def __init__(self, data: Mapping[str, str] | None = None, **kwargs: str) -> None:
|
|
18
|
+
"""Instantiate class."""
|
|
19
|
+
data = {} if data is None else {k.lower(): v for k, v in data.items()}
|
|
20
|
+
self._store = OrderedDict(data)
|
|
21
|
+
self._store.update(**{k.lower(): v for k, v in kwargs.items()})
|
|
22
|
+
|
|
23
|
+
def __getitem__(self, key: str) -> str:
|
|
24
|
+
"""Get value from object, ignoring case."""
|
|
25
|
+
return self._store[key.lower()]
|
|
26
|
+
|
|
27
|
+
def __hash__(self) -> int:
|
|
28
|
+
"""Make the object hashable."""
|
|
29
|
+
return hash(frozenset(self.items()))
|
|
30
|
+
|
|
31
|
+
def __iter__(self) -> Generator[str, str, None]:
|
|
32
|
+
"""Iterate over object."""
|
|
33
|
+
yield from iter(self._store)
|
|
34
|
+
|
|
35
|
+
def __len__(self) -> int:
|
|
36
|
+
"""Length of object."""
|
|
37
|
+
return len(self._store)
|
|
38
|
+
|
|
39
|
+
def find_value(self, value: re.Pattern[str] | str) -> CaseInsensitiveMapping:
|
|
40
|
+
"""Find value."""
|
|
41
|
+
value_pattern = re.compile(re.escape(value)) if isinstance(value, str) else value
|
|
42
|
+
rv: OrderedDict[str, str] = OrderedDict()
|
|
43
|
+
for k, v in self.items():
|
|
44
|
+
if value_pattern.match(v):
|
|
45
|
+
rv[k] = v
|
|
46
|
+
return CaseInsensitiveMapping(rv)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Roles."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
from typing import TYPE_CHECKING, Any
|
|
7
|
+
|
|
8
|
+
from docutils.nodes import reference
|
|
9
|
+
from docutils.utils import unescape
|
|
10
|
+
from sphinx.util.nodes import split_explicit_title
|
|
11
|
+
|
|
12
|
+
from ._case_insensitive_mapping import CaseInsensitiveMapping
|
|
13
|
+
from .constants import COMMON_LINKS
|
|
14
|
+
|
|
15
|
+
if TYPE_CHECKING:
|
|
16
|
+
from collections.abc import Sequence
|
|
17
|
+
|
|
18
|
+
from docutils.nodes import Node, system_message
|
|
19
|
+
from docutils.parsers.rst.states import Inliner
|
|
20
|
+
from sphinx.util.typing import RoleFunction
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@functools.cache
|
|
24
|
+
def _find_uri(links: CaseInsensitiveMapping, target: str) -> str:
|
|
25
|
+
"""Find URI with caching."""
|
|
26
|
+
return links[target]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def links_role(user_links: dict[str, str] | None = None) -> RoleFunction:
|
|
30
|
+
"""Generate link role function, injecting user provided collection of links."""
|
|
31
|
+
links = CaseInsensitiveMapping(COMMON_LINKS, **user_links if user_links else {})
|
|
32
|
+
|
|
33
|
+
def role_func(
|
|
34
|
+
role: str, # noqa: ARG001
|
|
35
|
+
rawtext: str, # noqa: ARG001
|
|
36
|
+
text: str,
|
|
37
|
+
lineno: int, # noqa: ARG001
|
|
38
|
+
inliner: Inliner, # noqa: ARG001
|
|
39
|
+
options: dict[str, Any] | None = None, # noqa: ARG001
|
|
40
|
+
content: Sequence[str] = (), # noqa: ARG001
|
|
41
|
+
) -> tuple[list[Node], list[system_message]]:
|
|
42
|
+
"""Implement role."""
|
|
43
|
+
_has_explicit_title, title, target = split_explicit_title(unescape(text))
|
|
44
|
+
node: Node = reference(
|
|
45
|
+
title, title, internal=False, refuri=_find_uri(links, target.lower())
|
|
46
|
+
)
|
|
47
|
+
return [node], []
|
|
48
|
+
|
|
49
|
+
return role_func
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"""External link checker."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from docutils.nodes import paragraph, reference, substitution_reference
|
|
9
|
+
from docutils.utils import new_document
|
|
10
|
+
from sphinx.transforms import SphinxTransform
|
|
11
|
+
from sphinx.transforms.post_transforms import SphinxPostTransform
|
|
12
|
+
from sphinx.util import logging
|
|
13
|
+
from sphinx.util.docutils import LoggingReporter
|
|
14
|
+
|
|
15
|
+
from ._case_insensitive_mapping import CaseInsensitiveMapping
|
|
16
|
+
from .constants import COMMON_LINKS
|
|
17
|
+
|
|
18
|
+
if TYPE_CHECKING:
|
|
19
|
+
from docutils.nodes import Node, document
|
|
20
|
+
|
|
21
|
+
LOGGER = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ExternalLinkChecker(SphinxPostTransform):
|
|
25
|
+
"""Check each external link to see if it can be replaced with a reference."""
|
|
26
|
+
|
|
27
|
+
_external_links: CaseInsensitiveMapping
|
|
28
|
+
default_priority = 501
|
|
29
|
+
|
|
30
|
+
def run(self, **_kwargs: object) -> None:
|
|
31
|
+
"""Main method of post transforms."""
|
|
32
|
+
if not self.config.external_links_detect_hardcoded_links:
|
|
33
|
+
return
|
|
34
|
+
|
|
35
|
+
self._external_links = CaseInsensitiveMapping(
|
|
36
|
+
COMMON_LINKS, **self.app.config.external_links
|
|
37
|
+
)
|
|
38
|
+
for refnode in self.document.findall(reference):
|
|
39
|
+
self.check_reference(refnode)
|
|
40
|
+
|
|
41
|
+
def check_reference(self, ref_node: reference) -> None:
|
|
42
|
+
"""Check if the reference can be replaced.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
links: Mapping of referencable links.
|
|
46
|
+
ref_node: The reference node to check.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
if "internal" in ref_node or "refuri" not in ref_node:
|
|
50
|
+
return
|
|
51
|
+
|
|
52
|
+
matches = self._external_links.find_value(
|
|
53
|
+
re.compile(re.escape(ref_node["refuri"]) + r"?(/)$")
|
|
54
|
+
)
|
|
55
|
+
if not matches:
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
LOGGER.warning(
|
|
59
|
+
'hardcoded link "%s" to %s could be replaced by a reference (%s)',
|
|
60
|
+
ref_node.astext(),
|
|
61
|
+
ref_node["refuri"],
|
|
62
|
+
", ".join(self.make_suggestions(matches, ref_node)),
|
|
63
|
+
location=ref_node,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
def make_suggestions(self, matches: CaseInsensitiveMapping, ref_node: reference) -> list[str]:
|
|
67
|
+
"""Make suggestions based on matches."""
|
|
68
|
+
title = ref_node.astext()
|
|
69
|
+
rv: list[str] = []
|
|
70
|
+
for k in matches:
|
|
71
|
+
if not ref_node["refuri"].startswith(title) and title == k:
|
|
72
|
+
rv.append(f":link:`{k}`")
|
|
73
|
+
else:
|
|
74
|
+
rv.append(f":link:`{title} <{k}>`")
|
|
75
|
+
return rv
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class GlobalSubstitutions(SphinxTransform):
|
|
79
|
+
"""Transform for global substitutions."""
|
|
80
|
+
|
|
81
|
+
default_priority = 211
|
|
82
|
+
|
|
83
|
+
def __init__(self, document: document, startnode: Node | None = None) -> None:
|
|
84
|
+
super().__init__(document, startnode)
|
|
85
|
+
self.parser = self.app.registry.create_source_parser(self.app, "rst")
|
|
86
|
+
|
|
87
|
+
def apply(self) -> None:
|
|
88
|
+
"""Apply substitutions."""
|
|
89
|
+
settings, source = self.document.settings, self.document["source"]
|
|
90
|
+
subs = self.document.settings.env.config.external_links_substitutions
|
|
91
|
+
to_handle = set(subs.keys()) - set(self.document.substitution_defs)
|
|
92
|
+
|
|
93
|
+
for ref in self.document.findall(substitution_reference):
|
|
94
|
+
refname = ref["refname"]
|
|
95
|
+
if refname in to_handle:
|
|
96
|
+
text = subs[refname]
|
|
97
|
+
|
|
98
|
+
doc = new_document(source, settings)
|
|
99
|
+
doc.reporter = LoggingReporter.from_reporter(doc.reporter)
|
|
100
|
+
self.parser.parse(text, doc)
|
|
101
|
+
|
|
102
|
+
substitution = doc.next_node()
|
|
103
|
+
# Remove encapsulating paragraph
|
|
104
|
+
if isinstance(substitution, paragraph):
|
|
105
|
+
substitution = substitution.next_node()
|
|
106
|
+
ref.replace_self(substitution)
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Constants."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from collections.abc import Mapping
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
COMMON_LINKS: Mapping[str, str] = {
|
|
12
|
+
"apache": "http://www.apache.org",
|
|
13
|
+
"apple": "http://www.apple.com/",
|
|
14
|
+
"black": "https://github.com/psf/black",
|
|
15
|
+
"couchdb": "http://couchdb.apache.org/",
|
|
16
|
+
"css": "http://www.w3.org/Style/CSS/",
|
|
17
|
+
"debian": "https://www.debian.org/",
|
|
18
|
+
"docker hub": "https://hub.docker.com/",
|
|
19
|
+
"docker": "http://docker.io/",
|
|
20
|
+
"gist": "https://gist.github.com/",
|
|
21
|
+
"gitlab": "https://gitlab.com/",
|
|
22
|
+
"google": "https://google.com/",
|
|
23
|
+
"jinja": "http://jinja.pocoo.org/",
|
|
24
|
+
"jinja2": "http://jinja.pocoo.org/",
|
|
25
|
+
"linux": "https://www.kernel.org/",
|
|
26
|
+
"macos": "http://www.apple.com/osx/",
|
|
27
|
+
"microsoft": "http://microsoft.com/",
|
|
28
|
+
"nginx": "http://nginx.org",
|
|
29
|
+
"nix": "http://nixos.org/nix/",
|
|
30
|
+
"npm": "https://www.npmjs.com/",
|
|
31
|
+
"poetry": "https://github.com/python-poetry/poetry",
|
|
32
|
+
"postgres": "http://www.postgresql.org/",
|
|
33
|
+
"postgresql": "http://www.postgresql.org/",
|
|
34
|
+
"pre-commit": "https://github.com/pre-commit/pre-commit",
|
|
35
|
+
"pydantic": "https://github.com/pydantic/pydantic",
|
|
36
|
+
"pypi": "https://pypi.org/",
|
|
37
|
+
"pyright": "https://github.com/microsoft/pyright",
|
|
38
|
+
"pytest": "https://github.com/pytest-dev/pytest/",
|
|
39
|
+
"python": "https://www.python.org/",
|
|
40
|
+
"rdt": "https://readthedocs.com/",
|
|
41
|
+
"readthedocs": "https://readthedocs.com/",
|
|
42
|
+
"restructuredtext": "https://docutils.sourceforge.io/rst.html",
|
|
43
|
+
"rich": "https://github.com/Textualize/rich",
|
|
44
|
+
"rst": "https://docutils.sourceforge.io/rst.html",
|
|
45
|
+
"ruff": "https://github.com/astral-sh/ruff",
|
|
46
|
+
"sphinx": "https://github.com/sphinx-doc/sphinx",
|
|
47
|
+
"sqlite": "http://www.sqlite.org/",
|
|
48
|
+
"test pypi": "https://test.pypi.org/",
|
|
49
|
+
"typeshed": "https://github.com/python/typeshed",
|
|
50
|
+
"ubuntu": "http://www.ubuntu.com/",
|
|
51
|
+
"visual studio code": "https://code.visualstudio.com/",
|
|
52
|
+
"vscode": "https://code.visualstudio.com/",
|
|
53
|
+
"w3c": "http://www.w3.org/",
|
|
54
|
+
"windows": "http://windows.microsoft.com/",
|
|
55
|
+
}
|
|
56
|
+
"""Mapping of common links."""
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Type definitions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import TypedDict
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ExtensionMetadata(TypedDict, total=False):
|
|
9
|
+
"""The metadata returned by an extension's ``setup()`` function.
|
|
10
|
+
|
|
11
|
+
Copy/paste for early use as it's staged for release in sphinx >7.2.6.
|
|
12
|
+
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
version: str
|
|
16
|
+
"""The extension version (default: ``'unknown version'``)."""
|
|
17
|
+
|
|
18
|
+
env_version: int
|
|
19
|
+
"""An integer that identifies the version of env data added by the extension."""
|
|
20
|
+
|
|
21
|
+
parallel_read_safe: bool
|
|
22
|
+
"""Indicate whether parallel reading of source files is supported
|
|
23
|
+
by the extension.
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
parallel_write_safe: bool
|
|
28
|
+
"""Indicate whether parallel writing of output files is supported
|
|
29
|
+
by the extension (default: ``True``).
|
|
30
|
+
|
|
31
|
+
"""
|