Skip to content

Commit 972d075

Browse files
committed
merge JsonStd and Std steps
1 parent ffd4078 commit 972d075

File tree

4 files changed

+34
-58
lines changed

4 files changed

+34
-58
lines changed

src/bootstrap/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,6 @@ impl<'a> Builder<'a> {
689689
doc::UnstableBookGen,
690690
doc::TheBook,
691691
doc::Standalone,
692-
doc::JsonStd,
693692
doc::Std,
694693
doc::Rustc,
695694
doc::Rustdoc,

src/bootstrap/dist.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use crate::cache::{Interned, INTERNER};
1919
use crate::channel;
2020
use crate::compile;
2121
use crate::config::TargetSelection;
22+
use crate::doc::DocumentationFormat;
2223
use crate::tarball::{GeneratedTarball, OverlayKind, Tarball};
2324
use crate::tool::{self, Tool};
2425
use crate::util::{exe, is_dylib, output, t, timeit};
@@ -97,7 +98,11 @@ impl Step for JsonDocs {
9798
/// Builds the `rust-docs-json` installer component.
9899
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
99100
let host = self.host;
100-
builder.ensure(crate::doc::JsonStd { stage: builder.top_stage, target: host });
101+
builder.ensure(crate::doc::Std {
102+
stage: builder.top_stage,
103+
target: host,
104+
format: DocumentationFormat::JSON,
105+
});
101106

102107
let dest = "share/doc/rust/json";
103108

src/bootstrap/doc.rs

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ impl Step for SharedAssets {
434434
pub struct Std {
435435
pub stage: u32,
436436
pub target: TargetSelection,
437+
pub format: DocumentationFormat,
437438
}
438439

439440
impl Step for Std {
@@ -446,7 +447,15 @@ impl Step for Std {
446447
}
447448

448449
fn make_run(run: RunConfig<'_>) {
449-
run.builder.ensure(Std { stage: run.builder.top_stage, target: run.target });
450+
run.builder.ensure(Std {
451+
stage: run.builder.top_stage,
452+
target: run.target,
453+
format: if run.builder.config.cmd.json() {
454+
DocumentationFormat::JSON
455+
} else {
456+
DocumentationFormat::HTML
457+
},
458+
});
450459
}
451460

452461
/// Compile all standard library documentation.
@@ -462,13 +471,16 @@ impl Step for Std {
462471
builder.ensure(SharedAssets { target: self.target });
463472

464473
let index_page = builder.src.join("src/doc/index.md").into_os_string();
465-
let mut extra_args = vec![
466-
OsStr::new("--markdown-css"),
467-
OsStr::new("rust.css"),
468-
OsStr::new("--markdown-no-toc"),
469-
OsStr::new("--index-page"),
470-
&index_page,
471-
];
474+
let mut extra_args = match self.format {
475+
DocumentationFormat::HTML => vec![
476+
OsStr::new("--markdown-css"),
477+
OsStr::new("rust.css"),
478+
OsStr::new("--markdown-no-toc"),
479+
OsStr::new("--index-page"),
480+
&index_page,
481+
],
482+
DocumentationFormat::JSON => vec![OsStr::new("--output-format"), OsStr::new("json")],
483+
};
472484

473485
if !builder.config.docs_minification {
474486
extra_args.push(OsStr::new("--disable-minification"));
@@ -492,15 +504,7 @@ impl Step for Std {
492504
})
493505
.collect::<Vec<_>>();
494506

495-
doc_std(
496-
builder,
497-
DocumentationFormat::HTML,
498-
stage,
499-
target,
500-
&out,
501-
&extra_args,
502-
&requested_crates,
503-
);
507+
doc_std(builder, self.format, stage, target, &out, &extra_args, &requested_crates);
504508

505509
// Look for library/std, library/core etc in the `x.py doc` arguments and
506510
// open the corresponding rendered docs.
@@ -513,43 +517,6 @@ impl Step for Std {
513517
}
514518
}
515519

516-
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
517-
pub struct JsonStd {
518-
pub stage: u32,
519-
pub target: TargetSelection,
520-
}
521-
522-
impl Step for JsonStd {
523-
type Output = ();
524-
const DEFAULT: bool = false;
525-
526-
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
527-
if run.builder.config.cmd.json() {
528-
let default = run.builder.config.docs && run.builder.config.cmd.json();
529-
run.all_krates("test").path("library").default_condition(default)
530-
} else {
531-
// Without this JsonStd would take priority on Std and prevent it from running.
532-
run.never()
533-
}
534-
}
535-
536-
fn make_run(run: RunConfig<'_>) {
537-
run.builder.ensure(JsonStd { stage: run.builder.top_stage, target: run.target });
538-
}
539-
540-
/// Build JSON documentation for the standard library crates.
541-
///
542-
/// This is largely just a wrapper around `cargo doc`.
543-
fn run(self, builder: &Builder<'_>) {
544-
let stage = self.stage;
545-
let target = self.target;
546-
let out = builder.json_doc_out(target);
547-
t!(fs::create_dir_all(&out));
548-
let extra_args = [OsStr::new("--output-format"), OsStr::new("json")];
549-
doc_std(builder, DocumentationFormat::JSON, stage, target, &out, &extra_args, &[])
550-
}
551-
}
552-
553520
/// Name of the crates that are visible to consumers of the standard library.
554521
/// Documentation for internal crates is handled by the rustc step, so internal crates will show
555522
/// up there.
@@ -562,7 +529,7 @@ impl Step for JsonStd {
562529
const STD_PUBLIC_CRATES: [&str; 5] = ["core", "alloc", "std", "proc_macro", "test"];
563530

564531
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
565-
enum DocumentationFormat {
532+
pub enum DocumentationFormat {
566533
HTML,
567534
JSON,
568535
}

src/bootstrap/test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::cache::Interned;
1616
use crate::compile;
1717
use crate::config::TargetSelection;
1818
use crate::dist;
19+
use crate::doc::DocumentationFormat;
1920
use crate::flags::Subcommand;
2021
use crate::native;
2122
use crate::tool::{self, SourceType, Tool};
@@ -822,7 +823,11 @@ impl Step for RustdocJSStd {
822823
command.arg("--test-file").arg(path);
823824
}
824825
}
825-
builder.ensure(crate::doc::Std { target: self.target, stage: builder.top_stage });
826+
builder.ensure(crate::doc::Std {
827+
target: self.target,
828+
stage: builder.top_stage,
829+
format: DocumentationFormat::HTML,
830+
});
826831
builder.run(&mut command);
827832
} else {
828833
builder.info("No nodejs found, skipping \"src/test/rustdoc-js-std\" tests");

0 commit comments

Comments
 (0)