diff --git a/src/packagedcode/cargo.py b/src/packagedcode/cargo.py index 3b2d342d828..aef4b78cb17 100644 --- a/src/packagedcode/cargo.py +++ b/src/packagedcode/cargo.py @@ -228,12 +228,12 @@ def parse(cls, location, package_only=False): vcs_url = core_package_data.get('repository') homepage_url = core_package_data.get('homepage') + documentation_url = core_package_data.get('documentation') repository_homepage_url = name and f'https://crates.io/crates/{name}' repository_download_url = name and version and f'https://crates.io/api/v1/crates/{name}/{version}/download' api_data_url = name and f'https://crates.io/api/v1/crates/{name}' extra_data_mappings = { - "documentation": "documentation_url", "rust-version": "rust_version", "edition": "rust_edition", } @@ -254,6 +254,7 @@ def parse(cls, location, package_only=False): extracted_license_statement=extracted_license_statement, vcs_url=vcs_url, homepage_url=homepage_url, + documentation_url=documentation_url, repository_homepage_url=repository_homepage_url, repository_download_url=repository_download_url, api_data_url=api_data_url, diff --git a/src/packagedcode/models.py b/src/packagedcode/models.py index 0c4ffb9e56e..781d696ee14 100644 --- a/src/packagedcode/models.py +++ b/src/packagedcode/models.py @@ -618,6 +618,10 @@ class PackageData(IdentifiablePackageData): 'See SPDX specification "Package Download Location" ' 'at https://spdx.org/spdx-specification-21-web-version#h.49x2ik5 ') + documentation_url = String( + label='documentation URL', + help='URL to the documentation for this package.') + copyright = String( label='Copyright', help='Copyright statements for this package. Typically one per line.') diff --git a/tests/packagedcode/data/cargo/cargo_toml/boring-child/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/boring-child/Cargo.toml.expected index 272e43f6a48..1b4092a4e0e 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/boring-child/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/boring-child/Cargo.toml.expected @@ -46,6 +46,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": null, + "documentation_url": "https://docs.rs/boring-sys", "copyright": null, "holder": null, "declared_license_expression": "mit", @@ -86,8 +87,7 @@ "extra_data": { "version": "workspace", "repository": "workspace", - "edition": "workspace", - "documentation_url": "https://docs.rs/boring-sys" + "edition": "workspace" }, "dependencies": [ { diff --git a/tests/packagedcode/data/cargo/cargo_toml/boring-main/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/boring-main/Cargo.toml.expected index a58452ebb84..e4cf9369cfe 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/boring-main/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/boring-main/Cargo.toml.expected @@ -21,6 +21,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": null, + "documentation_url": null, "copyright": null, "holder": null, "declared_license_expression": null, diff --git a/tests/packagedcode/data/cargo/cargo_toml/clap/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/clap/Cargo.toml.expected index 79b0a84c7c8..05fc95db445 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/clap/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/clap/Cargo.toml.expected @@ -36,6 +36,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "https://github.com/clap-rs/clap", + "documentation_url": "https://docs.rs/clap/", "copyright": null, "holder": null, "declared_license_expression": "mit", @@ -73,9 +74,7 @@ "file_references": [], "is_private": false, "is_virtual": false, - "extra_data": { - "documentation_url": "https://docs.rs/clap/" - }, + "extra_data": {}, "dependencies": [ { "purl": "pkg:cargo/bitflags", diff --git a/tests/packagedcode/data/cargo/cargo_toml/clippy/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/clippy/Cargo.toml.expected index e2566ada19f..dcb4a691a78 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/clippy/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/clippy/Cargo.toml.expected @@ -63,6 +63,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "https://github.com/rust-lang/rust-clippy", + "documentation_url": null, "copyright": null, "holder": null, "declared_license_expression": "mit OR apache-2.0", diff --git a/tests/packagedcode/data/cargo/cargo_toml/mdbook/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/mdbook/Cargo.toml.expected index f9489676f83..9cd00c8c958 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/mdbook/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/mdbook/Cargo.toml.expected @@ -48,6 +48,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "https://github.com/rust-lang-nursery/mdBook", + "documentation_url": "http://rust-lang-nursery.github.io/mdBook/index.html", "copyright": null, "holder": null, "declared_license_expression": "mpl-2.0", @@ -85,9 +86,7 @@ "file_references": [], "is_private": false, "is_virtual": false, - "extra_data": { - "documentation_url": "http://rust-lang-nursery.github.io/mdBook/index.html" - }, + "extra_data": {}, "dependencies": [ { "purl": "pkg:cargo/clap", diff --git a/tests/packagedcode/data/cargo/cargo_toml/rustfmt/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/rustfmt/Cargo.toml.expected index 6b0af2acdec..79013427b28 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/rustfmt/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/rustfmt/Cargo.toml.expected @@ -38,6 +38,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "https://github.com/rust-lang/rustfmt", + "documentation_url": null, "copyright": null, "holder": null, "declared_license_expression": "apache-2.0 OR mit", diff --git a/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected index 6a60afc8816..ad08f3ae54a 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/rustup/Cargo.toml.expected @@ -34,6 +34,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "https://github.com/rust-lang/rustup.rs", + "documentation_url": "http://rust-lang.github.io/rustup.rs/rustup/index.html", "copyright": null, "holder": null, "declared_license_expression": "mit OR apache-2.0", @@ -77,7 +78,6 @@ "src/download" ] }, - "documentation_url": "http://rust-lang.github.io/rustup.rs/rustup/index.html", "rust_edition": "2018" }, "dependencies": [ diff --git a/tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml.expected index ff00223cc82..dc5ab7516e2 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml.expected @@ -40,6 +40,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "https://github.com/cesarb/constant_time_eq", + "documentation_url": "https://docs.rs/constant_time_eq", "copyright": null, "holder": null, "declared_license_expression": "cc0-1.0 OR mit-0 OR apache-2.0", @@ -78,7 +79,6 @@ "is_private": false, "is_virtual": false, "extra_data": { - "documentation_url": "https://docs.rs/constant_time_eq", "rust_version": "1.85.0", "rust_edition": "2024" }, diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected index c07f809f9c5..4fce2752f5d 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri-examples/Cargo.toml.expected @@ -21,6 +21,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": null, + "documentation_url": null, "copyright": null, "holder": null, "declared_license_expression": null, diff --git a/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected index 25b7f94cd55..ae87e3cb414 100644 --- a/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected +++ b/tests/packagedcode/data/cargo/cargo_toml/tauri/Cargo.toml.expected @@ -21,6 +21,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": null, + "documentation_url": null, "copyright": null, "holder": null, "declared_license_expression": null, diff --git a/tests/packagedcode/data/models/full-expected.json b/tests/packagedcode/data/models/full-expected.json index f254042951c..4ff66d07bef 100644 --- a/tests/packagedcode/data/models/full-expected.json +++ b/tests/packagedcode/data/models/full-expected.json @@ -35,6 +35,7 @@ "bug_tracking_url": "http://homepage.com/issues", "code_view_url": "http://homepage.com/code", "vcs_url": "git+http://homepage.com/code.git@12ed302c4b4c2aa10638db3890", + "documentation_url": null, "copyright": "copyright (c) nexB Inc.", "holder": "nexB Inc.", "declared_license_expression": "apache-2.0", diff --git a/tests/packagedcode/data/models/simple-expected.json b/tests/packagedcode/data/models/simple-expected.json index 64432622056..2d7ccd90f07 100644 --- a/tests/packagedcode/data/models/simple-expected.json +++ b/tests/packagedcode/data/models/simple-expected.json @@ -31,6 +31,7 @@ "bug_tracking_url": null, "code_view_url": null, "vcs_url": "git+https://somerepo.com/that.git", + "documentation_url": null, "copyright": null, "holder": null, "declared_license_expression": "apache-2.0", diff --git a/tests/packagedcode/test_package_models.py b/tests/packagedcode/test_package_models.py index 0370054324f..51d783db5db 100644 --- a/tests/packagedcode/test_package_models.py +++ b/tests/packagedcode/test_package_models.py @@ -53,6 +53,7 @@ def test_Package_creation_and_dump(self): ('bug_tracking_url', None), ('code_view_url', None), ('vcs_url', None), + ('documentation_url', None), ('copyright', None), ('holder', None), ('declared_license_expression', None),