Skip to content

Commit 1f6c6bd

Browse files
committed
Auto merge of #8744 - roblabla:homepage-doc-cargo-metadata, r=alexcrichton
Homepage doc cargo metadata Adds two new field to cargo-metadata: `homepage` and `documentation`, lifted directly from the Cargo.toml. This additionally makes those fields available through `cargo read-manifest`.
2 parents 75615f8 + 26d1a25 commit 1f6c6bd

File tree

9 files changed

+119
-5
lines changed

9 files changed

+119
-5
lines changed

src/cargo/core/package.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ struct SerializedPackage<'a> {
9696
keywords: &'a [String],
9797
readme: Option<&'a str>,
9898
repository: Option<&'a str>,
99+
homepage: Option<&'a str>,
100+
documentation: Option<&'a str>,
99101
edition: &'a str,
100102
links: Option<&'a str>,
101103
#[serde(skip_serializing_if = "Option::is_none")]
@@ -118,6 +120,8 @@ impl ser::Serialize for Package {
118120
let keywords = manmeta.keywords.as_ref();
119121
let readme = manmeta.readme.as_deref();
120122
let repository = manmeta.repository.as_deref();
123+
let homepage = manmeta.homepage.as_ref().map(String::as_ref);
124+
let documentation = manmeta.documentation.as_ref().map(String::as_ref);
121125
// Filter out metabuild targets. They are an internal implementation
122126
// detail that is probably not relevant externally. There's also not a
123127
// real path to show in `src_path`, and this avoids changing the format.
@@ -146,6 +150,8 @@ impl ser::Serialize for Package {
146150
keywords,
147151
readme,
148152
repository,
153+
homepage,
154+
documentation,
149155
edition: &self.manifest().edition().to_string(),
150156
links: self.manifest().links(),
151157
metabuild: self.manifest().metabuild(),

src/doc/man/cargo-metadata.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ The output has the following format:
182182
"readme": "README.md",
183183
/* The repository value from the manifest or null if not specified. */
184184
"repository": "https://github.com/rust-lang/cargo",
185+
/* The homepage value from the manifest or null if not specified. */
186+
"homepage": "https://rust-lang.org",
187+
/* The documentation value from the manifest or null if not specified. */
188+
"documentation": "https://doc.rust-lang.org/stable/std",
185189
/* The default edition of the package.
186190
Note that individual targets may have different editions.
187191
*/

src/doc/man/generated_txt/cargo-metadata.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ OUTPUT FORMAT
177177
"readme": "README.md",
178178
/* The repository value from the manifest or null if not specified. */
179179
"repository": "https://github.com/rust-lang/cargo",
180+
/* The homepage value from the manifest or null if not specified. */
181+
"homepage": "https://rust-lang.org",
182+
/* The documentation value from the manifest or null if not specified. */
183+
"documentation": "https://doc.rust-lang.org/stable/std",
180184
/* The default edition of the package.
181185
Note that individual targets may have different editions.
182186
*/

src/doc/src/commands/cargo-metadata.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ The output has the following format:
182182
"readme": "README.md",
183183
/* The repository value from the manifest or null if not specified. */
184184
"repository": "https://github.com/rust-lang/cargo",
185+
/* The homepage value from the manifest or null if not specified. */
186+
"homepage": "https://rust-lang.org",
187+
/* The documentation value from the manifest or null if not specified. */
188+
"documentation": "https://doc.rust-lang.org/stable/std",
185189
/* The default edition of the package.
186190
Note that individual targets may have different editions.
187191
*/

src/etc/man/cargo-metadata.1

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ The output has the following format:
179179
"readme": "README.md",
180180
/* The repository value from the manifest or null if not specified. */
181181
"repository": "https://github.com/rust\-lang/cargo",
182+
/* The homepage value from the manifest or null if not specified. */
183+
"homepage": "https://rust-lang.org",
184+
/* The documentation value from the manifest or null if not specified. */
185+
"documentation": "https://doc.rust-lang.org/stable/std",
182186
/* The default edition of the package.
183187
Note that individual targets may have different editions.
184188
*/
@@ -329,7 +333,7 @@ Do not activate the \fBdefault\fR feature of the current directory's package.
329333
.RE
330334
.SS "Display Options"
331335
.sp
332-
\fB\-v\fR,
336+
\fB\-v\fR,
333337
\fB\-\-verbose\fR
334338
.RS 4
335339
Use verbose output. May be specified twice for "very verbose" output which
@@ -338,7 +342,7 @@ May also be specified with the \fBterm.verbose\fR
338342
\fIconfig value\fR <https://doc.rust\-lang.org/cargo/reference/config.html>\&.
339343
.RE
340344
.sp
341-
\fB\-q\fR,
345+
\fB\-q\fR,
342346
\fB\-\-quiet\fR
343347
.RS 4
344348
No output printed to stdout.
@@ -372,7 +376,7 @@ Path to the \fBCargo.toml\fR file. By default, Cargo searches for the
372376
\fBCargo.toml\fR file in the current directory or any parent directory.
373377
.RE
374378
.sp
375-
\fB\-\-frozen\fR,
379+
\fB\-\-frozen\fR,
376380
\fB\-\-locked\fR
377381
.RS 4
378382
Either of these flags requires that the \fBCargo.lock\fR file is
@@ -411,7 +415,7 @@ See the \fIrustup documentation\fR <https://rust\-lang.github.io/rustup/override
411415
for more information about how toolchain overrides work.
412416
.RE
413417
.sp
414-
\fB\-h\fR,
418+
\fB\-h\fR,
415419
\fB\-\-help\fR
416420
.RS 4
417421
Prints help information.

tests/testsuite/alt_registry.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ fn publish_with_registry_dependency() {
359359
"readme": null,
360360
"readme_file": null,
361361
"repository": null,
362+
"homepage": null,
363+
"documentation": null,
362364
"vers": "0.0.1"
363365
}"#,
364366
"foo-0.0.1.crate",
@@ -459,6 +461,8 @@ fn publish_to_alt_registry() {
459461
"readme": null,
460462
"readme_file": null,
461463
"repository": null,
464+
"homepage": null,
465+
"documentation": null,
462466
"vers": "0.0.1"
463467
}"#,
464468
"foo-0.0.1.crate",
@@ -522,6 +526,8 @@ fn publish_with_crates_io_dep() {
522526
"readme": null,
523527
"readme_file": null,
524528
"repository": null,
529+
"homepage": null,
530+
"documentation": null,
525531
"vers": "0.0.1"
526532
}"#,
527533
"foo-0.0.1.crate",
@@ -814,6 +820,8 @@ fn alt_reg_metadata() {
814820
"keywords": [],
815821
"readme": null,
816822
"repository": null,
823+
"homepage": null,
824+
"documentation": null,
817825
"edition": "2015",
818826
"links": null
819827
}
@@ -868,6 +876,8 @@ fn alt_reg_metadata() {
868876
"keywords": [],
869877
"readme": null,
870878
"repository": null,
879+
"homepage": null,
880+
"documentation": null,
871881
"edition": "2015",
872882
"links": null
873883
},
@@ -890,6 +900,8 @@ fn alt_reg_metadata() {
890900
"keywords": [],
891901
"readme": null,
892902
"repository": null,
903+
"homepage": null,
904+
"documentation": null,
893905
"edition": "2015",
894906
"links": null
895907
},
@@ -912,6 +924,8 @@ fn alt_reg_metadata() {
912924
"keywords": [],
913925
"readme": null,
914926
"repository": null,
927+
"homepage": null,
928+
"documentation": null,
915929
"edition": "2015",
916930
"links": null
917931
},
@@ -959,6 +973,8 @@ fn alt_reg_metadata() {
959973
"keywords": [],
960974
"readme": null,
961975
"repository": null,
976+
"homepage": null,
977+
"documentation": null,
962978
"edition": "2015",
963979
"links": null
964980
},
@@ -994,6 +1010,8 @@ fn alt_reg_metadata() {
9941010
"keywords": [],
9951011
"readme": null,
9961012
"repository": null,
1013+
"homepage": null,
1014+
"documentation": null,
9971015
"edition": "2015",
9981016
"links": null
9991017
}
@@ -1087,6 +1105,8 @@ fn unknown_registry() {
10871105
"keywords": [],
10881106
"readme": null,
10891107
"repository": null,
1108+
"homepage": null,
1109+
"documentation": null,
10901110
"edition": "2015",
10911111
"links": null
10921112
},
@@ -1109,6 +1129,8 @@ fn unknown_registry() {
11091129
"keywords": [],
11101130
"readme": null,
11111131
"repository": null,
1132+
"homepage": null,
1133+
"documentation": null,
11121134
"edition": "2015",
11131135
"links": null
11141136
},
@@ -1144,6 +1166,8 @@ fn unknown_registry() {
11441166
"keywords": [],
11451167
"readme": null,
11461168
"repository": null,
1169+
"homepage": null,
1170+
"documentation": null,
11471171
"edition": "2015",
11481172
"links": null
11491173
}

0 commit comments

Comments
 (0)