Skip to content

Commit e912219

Browse files
committed
generate license list from cargo tree
1 parent bd49fcc commit e912219

File tree

3 files changed

+74
-48
lines changed

3 files changed

+74
-48
lines changed

docs/docs/other-licenses.md

+3-48
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,5 @@
11
# Third-party Licenses
22

3-
- [clap](https://crates.io/crates/clap):
4-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
5-
- [git2](https://crates.io/crates/git2):
6-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
7-
8-
The following are conditionally included in binaries (using the `openssl-vendored` feature on a
9-
case-by-case basis) because it is a dependency of git2:
10-
11-
- [openssl](https://crates.io/crates/openssl): Licensed under [Apache 2.0][Apache2]
12-
- [openssl-probe](https://crates.io/crates/openssl-probe):
13-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
14-
15-
- [lenient_semver](https://crates.io/crates/lenient_semver):
16-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
17-
- [log](https://crates.io/crates/log):
18-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
19-
- [regex](https://crates.io/crates/regex):
20-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
21-
- [reqwest](https://crates.io/crates/reqwest):
22-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
23-
- [semver](https://crates.io/crates/semver):
24-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
25-
- [serde](https://crates.io/crates/serde):
26-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
27-
- [serde-xml-rs](https://crates.io/crates/serde-xml-rs): Licensed under [MIT].
28-
- [serde_json](https://crates.io/crates/serde_json):
29-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
30-
- [which](https://crates.io/crates/which): Licensed under [MIT].
31-
- [tokio](https://crates.io/crates/tokio): Licensed under [MIT].
32-
- [futures](https://crates.io/crates/futures):
33-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
34-
- [chrono](https://crates.io/crates/chrono):
35-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
36-
- [colored](https://crates.io/crates/colored): Licensed under [MPL-2.0]
37-
38-
The python binding uses
39-
40-
- [pyo3](https://crates.io/crates/pyo3):
41-
Dual-licensed under [Apache 2.0][Apache2] or [MIT].
42-
43-
The node binding uses
44-
45-
- [napi](https://crates.io/crates/napi): Licensed under [MIT]
46-
- [napi-derive](https://crates.io/crates/napi-derive): Licensed under [MIT]
47-
48-
[MIT]: https://choosealicense.com/licenses/mit
49-
[Apache2]: https://choosealicense.com/licenses/apache-2.0/
50-
[MPL-2.0]: https://choosealicense.com/licenses/mpl-2.0
3+
This page is generated when mkdocs builds.
4+
All content here is overwritten when building the docs.
5+
For changes to this document, please refer to [license_gen.py](../license_gen.py).

docs/license_gen.py

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import mkdocs_gen_files
2+
from subprocess import run
3+
4+
FILENAME = "other-licenses.md"
5+
6+
INTRO = """# Third-party Licenses
7+
8+
[MIT]: https://choosealicense.com/licenses/mit
9+
[Apache-2.0]: https://choosealicense.com/licenses/apache-2.0/
10+
[MPL-2.0]: https://choosealicense.com/licenses/mpl-2.0
11+
"""
12+
13+
OPTIONAL_DEPS = """## Optional dependencies
14+
15+
The following are conditionally included in binaries (using the `openssl-vendored`
16+
feature on a case-by-case basis) because it is a dependency of
17+
[git2](https://crates.io/crates/git2):
18+
19+
- [openssl](https://crates.io/crates/openssl): Licensed under [Apache-2.0].
20+
- [openssl-probe](https://crates.io/crates/openssl-probe):
21+
Dual-licensed under [Apache-2.0] or [MIT].
22+
"""
23+
24+
BINDING_DEPS = """## Bindings' dependencies
25+
26+
The python binding uses
27+
28+
- [pyo3](https://crates.io/crates/pyo3):
29+
Dual-licensed under [Apache-2.0] or [MIT].
30+
31+
The node binding uses
32+
33+
- [napi](https://crates.io/crates/napi): Licensed under [MIT]
34+
- [napi-derive](https://crates.io/crates/napi-derive): Licensed under [MIT]
35+
"""
36+
37+
with mkdocs_gen_files.open(FILENAME, "w") as io_doc:
38+
print(INTRO, file=io_doc)
39+
output = run(
40+
[
41+
"cargo",
42+
"tree",
43+
"-f",
44+
r"[{p}]({r}): Licensed under {l}",
45+
"-e",
46+
"normal",
47+
"-p",
48+
"cpp-linter",
49+
"--depth",
50+
"1",
51+
],
52+
capture_output=True,
53+
check=True,
54+
)
55+
doc = "\n".join(
56+
[
57+
"- "
58+
+ line[3:]
59+
.replace(" MIT", " [MIT]")
60+
.replace(" Apache-2.0", " [Apache-2.0]")
61+
.replace(" MPL-2.0", " [MPL-2.0]")
62+
for line in output.stdout.decode(encoding="utf-8").splitlines()[1:]
63+
]
64+
)
65+
# print(doc)
66+
print(doc, file=io_doc)
67+
print(f"\n{OPTIONAL_DEPS}\n", file=io_doc)
68+
print(f"\n{BINDING_DEPS}\n", file=io_doc)
69+
70+
mkdocs_gen_files.set_edit_path(FILENAME, "license-gen.py")

docs/mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ plugins:
7979
- gen-files:
8080
scripts:
8181
- gen_cli_doc.py
82+
- license_gen.py
8283

8384
markdown_extensions:
8485
- pymdownx.superfences

0 commit comments

Comments
 (0)