Skip to content

Commit 3c1f774

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

File tree

3 files changed

+75
-48
lines changed

3 files changed

+75
-48
lines changed

docs/docs/other-licenses.md

Lines changed: 3 additions & 48 deletions
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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
20+
- [openssl](https://crates.io/crates/openssl): Licensed under [Apache-2.0].
21+
- [openssl-probe](https://crates.io/crates/openssl-probe):
22+
Dual-licensed under [Apache-2.0] or [MIT].
23+
"""
24+
25+
BINDING_DEPS = """## Bindings' dependencies
26+
27+
The python binding uses
28+
29+
- [pyo3](https://crates.io/crates/pyo3):
30+
Dual-licensed under [Apache-2.0] or [MIT].
31+
32+
The node binding uses
33+
34+
- [napi](https://crates.io/crates/napi): Licensed under [MIT]
35+
- [napi-derive](https://crates.io/crates/napi-derive): Licensed under [MIT]
36+
"""
37+
38+
with mkdocs_gen_files.open(FILENAME, "w") as io_doc:
39+
print(INTRO, file=io_doc)
40+
output = run(
41+
[
42+
"cargo",
43+
"tree",
44+
"-f",
45+
r"[{p}]({r}): Licensed under {l}",
46+
"-e",
47+
"normal",
48+
"-p",
49+
"cpp-linter",
50+
"--depth",
51+
"1",
52+
],
53+
capture_output=True,
54+
check=True,
55+
)
56+
doc = "\n".join(
57+
[
58+
"- "
59+
+ line[3:]
60+
.replace(" MIT", " [MIT]")
61+
.replace(" Apache-2.0", " [Apache-2.0]")
62+
.replace(" MPL-2.0", " [MPL-2.0]")
63+
for line in output.stdout.decode(encoding="utf-8").splitlines()[1:]
64+
]
65+
)
66+
# print(doc)
67+
print(doc, file=io_doc)
68+
print(f"\n{OPTIONAL_DEPS}\n", file=io_doc)
69+
print(f"\n{BINDING_DEPS}\n", file=io_doc)
70+
71+
mkdocs_gen_files.set_edit_path(FILENAME, "license-gen.py")

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
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)