Skip to content

Commit daccb3d

Browse files
committed
Auto merge of #105036 - jyn514:cargo-docs, r=Mark-Simulacrum
Support documenting cargo The primary motivation is to have the cargo docs show up on https://doc.rust-lang.org/nightly/nightly-rustc/cargo, but as a nice side effect this makes `x doc cargo` work locally. cc `@rust-lang/cargo`
2 parents 8a97b48 + f94c926 commit daccb3d

File tree

5 files changed

+160
-24
lines changed

5 files changed

+160
-24
lines changed

Diff for: Cargo.lock

+104-13
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ dependencies = [
7777
"yansi-term",
7878
]
7979

80+
[[package]]
81+
name = "ansi_term"
82+
version = "0.11.0"
83+
source = "registry+https://github.com/rust-lang/crates.io-index"
84+
checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
85+
dependencies = [
86+
"winapi",
87+
]
88+
8089
[[package]]
8190
name = "ansi_term"
8291
version = "0.12.1"
@@ -707,7 +716,7 @@ dependencies = [
707716
"declare_clippy_lint",
708717
"if_chain",
709718
"itertools",
710-
"pulldown-cmark",
719+
"pulldown-cmark 0.9.2",
711720
"quine-mc_cluskey",
712721
"regex-syntax",
713722
"rustc-semver",
@@ -1028,6 +1037,16 @@ dependencies = [
10281037
"quote",
10291038
]
10301039

1040+
[[package]]
1041+
name = "ctor"
1042+
version = "0.1.26"
1043+
source = "registry+https://github.com/rust-lang/crates.io-index"
1044+
checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
1045+
dependencies = [
1046+
"quote",
1047+
"syn",
1048+
]
1049+
10311050
[[package]]
10321051
name = "curl"
10331052
version = "0.4.44"
@@ -1104,6 +1123,12 @@ version = "0.1.13"
11041123
source = "registry+https://github.com/rust-lang/crates.io-index"
11051124
checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
11061125

1126+
[[package]]
1127+
name = "difference"
1128+
version = "2.0.0"
1129+
source = "registry+https://github.com/rust-lang/crates.io-index"
1130+
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
1131+
11071132
[[package]]
11081133
name = "digest"
11091134
version = "0.10.2"
@@ -1683,6 +1708,21 @@ dependencies = [
16831708
"serde",
16841709
]
16851710

1711+
[[package]]
1712+
name = "handlebars"
1713+
version = "3.5.5"
1714+
source = "registry+https://github.com/rust-lang/crates.io-index"
1715+
checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3"
1716+
dependencies = [
1717+
"log",
1718+
"pest",
1719+
"pest_derive",
1720+
"quick-error 2.0.1",
1721+
"serde",
1722+
"serde_json",
1723+
"walkdir",
1724+
]
1725+
16861726
[[package]]
16871727
name = "handlebars"
16881728
version = "4.3.3"
@@ -1794,7 +1834,7 @@ version = "1.3.0"
17941834
source = "registry+https://github.com/rust-lang/crates.io-index"
17951835
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
17961836
dependencies = [
1797-
"quick-error",
1837+
"quick-error 1.2.3",
17981838
]
17991839

18001840
[[package]]
@@ -1990,19 +2030,19 @@ dependencies = [
19902030

19912031
[[package]]
19922032
name = "io-lifetimes"
1993-
version = "1.0.2"
2033+
version = "1.0.3"
19942034
source = "registry+https://github.com/rust-lang/crates.io-index"
1995-
checksum = "e394faa0efb47f9f227f1cd89978f854542b318a6f64fa695489c9c993056656"
2035+
checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c"
19962036
dependencies = [
19972037
"libc",
19982038
"windows-sys",
19992039
]
20002040

20012041
[[package]]
20022042
name = "is-terminal"
2003-
version = "0.4.0"
2043+
version = "0.4.2"
20042044
source = "registry+https://github.com/rust-lang/crates.io-index"
2005-
checksum = "aae5bc6e2eb41c9def29a3e0f1306382807764b9b53112030eff57435667352d"
2045+
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
20062046
dependencies = [
20072047
"hermit-abi 0.2.6",
20082048
"io-lifetimes",
@@ -2221,9 +2261,9 @@ dependencies = [
22212261

22222262
[[package]]
22232263
name = "linux-raw-sys"
2224-
version = "0.1.3"
2264+
version = "0.1.4"
22252265
source = "registry+https://github.com/rust-lang/crates.io-index"
2226-
checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f"
2266+
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
22272267

22282268
[[package]]
22292269
name = "litemap"
@@ -2328,12 +2368,12 @@ dependencies = [
23282368
"clap_complete",
23292369
"elasticlunr-rs",
23302370
"env_logger 0.9.0",
2331-
"handlebars",
2371+
"handlebars 4.3.3",
23322372
"lazy_static",
23332373
"log",
23342374
"memchr",
23352375
"opener",
2336-
"pulldown-cmark",
2376+
"pulldown-cmark 0.9.2",
23372377
"regex",
23382378
"serde",
23392379
"serde_json",
@@ -2343,6 +2383,19 @@ dependencies = [
23432383
"topological-sort",
23442384
]
23452385

2386+
[[package]]
2387+
name = "mdman"
2388+
version = "0.1.0"
2389+
dependencies = [
2390+
"anyhow",
2391+
"handlebars 3.5.5",
2392+
"pretty_assertions",
2393+
"pulldown-cmark 0.7.2",
2394+
"same-file",
2395+
"serde_json",
2396+
"url",
2397+
]
2398+
23462399
[[package]]
23472400
name = "measureme"
23482401
version = "10.1.0"
@@ -2617,6 +2670,15 @@ version = "6.0.0"
26172670
source = "registry+https://github.com/rust-lang/crates.io-index"
26182671
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
26192672

2673+
[[package]]
2674+
name = "output_vt100"
2675+
version = "0.1.3"
2676+
source = "registry+https://github.com/rust-lang/crates.io-index"
2677+
checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
2678+
dependencies = [
2679+
"winapi",
2680+
]
2681+
26202682
[[package]]
26212683
name = "owo-colors"
26222684
version = "3.4.0"
@@ -2858,6 +2920,18 @@ version = "0.1.1"
28582920
source = "registry+https://github.com/rust-lang/crates.io-index"
28592921
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
28602922

2923+
[[package]]
2924+
name = "pretty_assertions"
2925+
version = "0.6.1"
2926+
source = "registry+https://github.com/rust-lang/crates.io-index"
2927+
checksum = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
2928+
dependencies = [
2929+
"ansi_term 0.11.0",
2930+
"ctor",
2931+
"difference",
2932+
"output_vt100",
2933+
]
2934+
28612935
[[package]]
28622936
name = "pretty_env_logger"
28632937
version = "0.4.0"
@@ -2933,6 +3007,17 @@ dependencies = [
29333007
"cc",
29343008
]
29353009

3010+
[[package]]
3011+
name = "pulldown-cmark"
3012+
version = "0.7.2"
3013+
source = "registry+https://github.com/rust-lang/crates.io-index"
3014+
checksum = "ca36dea94d187597e104a5c8e4b07576a8a45aa5db48a65e12940d3eb7461f55"
3015+
dependencies = [
3016+
"bitflags",
3017+
"memchr",
3018+
"unicase",
3019+
]
3020+
29363021
[[package]]
29373022
name = "pulldown-cmark"
29383023
version = "0.9.2"
@@ -2956,6 +3041,12 @@ version = "1.2.3"
29563041
source = "registry+https://github.com/rust-lang/crates.io-index"
29573042
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
29583043

3044+
[[package]]
3045+
name = "quick-error"
3046+
version = "2.0.1"
3047+
source = "registry+https://github.com/rust-lang/crates.io-index"
3048+
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
3049+
29593050
[[package]]
29603051
name = "quine-mc_cluskey"
29613052
version = "0.2.4"
@@ -4545,7 +4636,7 @@ dependencies = [
45454636
"itertools",
45464637
"minifier",
45474638
"once_cell",
4548-
"pulldown-cmark",
4639+
"pulldown-cmark 0.9.2",
45494640
"rayon",
45504641
"regex",
45514642
"rustdoc-json-types",
@@ -5375,7 +5466,7 @@ version = "0.3.3"
53755466
source = "registry+https://github.com/rust-lang/crates.io-index"
53765467
checksum = "245da694cc7fc4729f3f418b304cb57789f1bed2a78c575407ab8a23f53cb4d3"
53775468
dependencies = [
5378-
"ansi_term",
5469+
"ansi_term 0.12.1",
53795470
"lazy_static",
53805471
"matchers",
53815472
"parking_lot 0.11.2",
@@ -5394,7 +5485,7 @@ version = "0.2.0"
53945485
source = "registry+https://github.com/rust-lang/crates.io-index"
53955486
checksum = "3ce989c9962c7f61fe084dd4a230eec784649dfc2392467c790007c3a6e134e7"
53965487
dependencies = [
5397-
"ansi_term",
5488+
"ansi_term 0.12.1",
53985489
"atty",
53995490
"tracing-core",
54005491
"tracing-log",

Diff for: Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ members = [
2525
"src/tools/cargo/crates/credential/cargo-credential-1password",
2626
"src/tools/cargo/crates/credential/cargo-credential-macos-keychain",
2727
"src/tools/cargo/crates/credential/cargo-credential-wincred",
28+
"src/tools/cargo/crates/mdman",
29+
# "src/tools/cargo/crates/resolver-tests",
2830
"src/tools/rustdoc",
2931
"src/tools/rls",
3032
"src/tools/rustfmt",

Diff for: src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ impl<'a> Builder<'a> {
702702
doc::RustdocBook,
703703
doc::RustByExample,
704704
doc::RustcBook,
705+
doc::Cargo,
705706
doc::CargoBook,
706707
doc::Clippy,
707708
doc::ClippyBook,

Diff for: src/bootstrap/doc.rs

+52-11
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ impl Step for Rustc {
729729
}
730730

731731
macro_rules! tool_doc {
732-
($tool: ident, $should_run: literal, $path: literal, [$($krate: literal),+ $(,)?] $(,)?) => {
732+
($tool: ident, $should_run: literal, $path: literal, $(rustc_tool = $rustc_tool:literal, )? $(in_tree = $in_tree:literal, )? [$($krate: literal),+ $(,)?] $(,)?) => {
733733
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
734734
pub struct $tool {
735735
target: TargetSelection,
@@ -763,13 +763,24 @@ macro_rules! tool_doc {
763763
let out = builder.compiler_doc_out(target);
764764
t!(fs::create_dir_all(&out));
765765

766-
// Build rustc docs so that we generate relative links.
767-
builder.ensure(Rustc { stage, target });
768-
// Rustdoc needs the rustc sysroot available to build.
769-
// FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
770-
// with strange errors, but only on a full bors test ...
771766
let compiler = builder.compiler(stage, builder.config.build);
772-
builder.ensure(compile::Rustc::new(compiler, target));
767+
builder.ensure(compile::Std::new(compiler, target));
768+
769+
if true $(&& $rustc_tool)? {
770+
// Build rustc docs so that we generate relative links.
771+
builder.ensure(Rustc { stage, target });
772+
773+
// Rustdoc needs the rustc sysroot available to build.
774+
// FIXME: is there a way to only ensure `check::Rustc` here? Last time I tried it failed
775+
// with strange errors, but only on a full bors test ...
776+
builder.ensure(compile::Rustc::new(compiler, target));
777+
}
778+
779+
let source_type = if true $(&& $in_tree)? {
780+
SourceType::InTree
781+
} else {
782+
SourceType::Submodule
783+
};
773784

774785
builder.info(
775786
&format!(
@@ -781,9 +792,15 @@ macro_rules! tool_doc {
781792
);
782793

783794
// Symlink compiler docs to the output directory of rustdoc documentation.
784-
let out_dir = builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc");
785-
t!(fs::create_dir_all(&out_dir));
786-
t!(symlink_dir_force(&builder.config, &out, &out_dir));
795+
let out_dirs = [
796+
builder.stage_out(compiler, Mode::ToolRustc).join(target.triple).join("doc"),
797+
// Cargo uses a different directory for proc macros.
798+
builder.stage_out(compiler, Mode::ToolRustc).join("doc"),
799+
];
800+
for out_dir in out_dirs {
801+
t!(fs::create_dir_all(&out_dir));
802+
t!(symlink_dir_force(&builder.config, &out, &out_dir));
803+
}
787804

788805
// Build cargo command.
789806
let mut cargo = prepare_tool_cargo(
@@ -793,7 +810,7 @@ macro_rules! tool_doc {
793810
target,
794811
"doc",
795812
$path,
796-
SourceType::InTree,
813+
source_type,
797814
&[],
798815
);
799816

@@ -824,6 +841,30 @@ tool_doc!(
824841
);
825842
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);
826843
tool_doc!(Miri, "miri", "src/tools/miri", ["miri"]);
844+
tool_doc!(
845+
Cargo,
846+
"cargo",
847+
"src/tools/cargo",
848+
rustc_tool = false,
849+
in_tree = false,
850+
[
851+
"cargo",
852+
"cargo-platform",
853+
"cargo-util",
854+
"crates-io",
855+
"cargo-test-macro",
856+
"cargo-test-support",
857+
"cargo-credential",
858+
"cargo-credential-1password",
859+
"mdman",
860+
// FIXME: this trips a license check in tidy.
861+
// "resolver-tests",
862+
// FIXME: we should probably document these, but they're different per-platform so we can't use `tool_doc`.
863+
// "cargo-credential-gnome-secret",
864+
// "cargo-credential-macos-keychain",
865+
// "cargo-credential-wincred",
866+
]
867+
);
827868

828869
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
829870
pub struct ErrorIndex {

Diff for: src/bootstrap/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &'static str, Option<&[&'static str]>)]
202202
(None, "bootstrap", None),
203203
(Some(Mode::Rustc), "parallel_compiler", None),
204204
(Some(Mode::ToolRustc), "parallel_compiler", None),
205+
(Some(Mode::ToolRustc), "emulate_second_only_system", None),
205206
(Some(Mode::Codegen), "parallel_compiler", None),
206207
(Some(Mode::Std), "stdarch_intel_sde", None),
207208
(Some(Mode::Std), "no_fp_fmt_parse", None),

0 commit comments

Comments
 (0)