-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Simplify doc meta mode #159473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Simplify doc meta mode #159473
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -206,17 +206,15 @@ This is very easy to use in scripts that manually invoke rustdoc, but it's also | |||||
| performs O(crates) work on every crate, meaning it performs O(crates<sup>2</sup>) work. When | ||||||
| `--write-doc-meta-dir` and/or `--read-doc-meta-dir` are supplied, this is turned off. | ||||||
|
|
||||||
| When `--write-doc-meta-dir` is supplied, rustdoc will write the crate's metadata to that directory. | ||||||
| If this parameter is supplied but `--read-doc-meta-dir` isn't, it runs in *intermediate mode*: | ||||||
| some pages may be written to the output dir, but there is a lot of functionality that won't work | ||||||
| until rustdoc is run in *finalize mode*. | ||||||
| When `--write-doc-meta-dir` is supplied, rustdoc will write the crate's shared metadata to | ||||||
| that directory. This is an *intermediate mode* where it may write some files to the doc output | ||||||
| directory, but some features won't work until it is finalized. | ||||||
|
|
||||||
| When `--read-doc-meta-dir` is supplied, rustdoc runs in *finalize mode*. It will read the data from | ||||||
| the supplied directory, and will write it to the doc output directory in the form that the web | ||||||
| frontend will use. | ||||||
| When `--read-doc-meta-dir` is supplied, it runs it in *finalize mode*. No crate source code is | ||||||
| passed to rustdoc when it runs in this mode. Multiple `--read-doc-meta-dir` can be passed to | ||||||
| rustdoc, so your build system can split the state between multiple directories if that helps. | ||||||
|
|
||||||
| If both `--write-doc-meta-dir` and `--read-doc-meta-dir` are specified, the crate metadata will be | ||||||
| written to both the HTML `--out-dir` and to the supplied `--write-doc-meta-dir`. | ||||||
| Both `--write-doc-meta-dir` and `--read-doc-meta-dir` can't be supplied at once. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```console | ||||||
| $ rustdoc crate1.rs --out-dir=doc | ||||||
|
|
@@ -231,10 +229,13 @@ To delay shared-data merging until the end of a build, so that you only have to | |||||
| work, use `--write-doc-meta-dir` on every crate, and the last will use `--read-doc-meta-dir`. | ||||||
|
|
||||||
| ```console | ||||||
| $ rustdoc +nightly crate1.rs --write-doc-meta=crate1.d -Zunstable-options | ||||||
| $ rustdoc +nightly crate1.rs --write-doc-meta-dir=crate1.d -Zunstable-options | ||||||
| $ cat doc/search.index/crateNames/* | ||||||
| cat: 'doc/search.index/crateNames/*': No such file or directory | ||||||
| $ rustdoc +nightly crate2.rs --read-doc-meta=crate1.d -Zunstable-options | ||||||
| $ rustdoc +nightly crate2.rs --write-doc-meta-dir=crate2.d -Zunstable-options | ||||||
| $ cat doc/search.index/crateNames/* | ||||||
| cat: 'doc/search.index/crateNames/*': No such file or directory | ||||||
| $ rustdoc +nightly --read-doc-meta-dir=crate1.d --read-doc-meta-dir=crate2.d -Zunstable-options | ||||||
| $ cat doc/search.index/crateNames/* | ||||||
| rd_("fcrate1fcrate2") | ||||||
| ``` | ||||||
|
|
||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't fully understand the purpose of the changes in this commit. Did |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the check that errors when both |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| //@ needs-target-std | ||
|
|
||
| use run_make_support::{cwd, htmldocck, path, rust_lib_name, rustc, rustdoc}; | ||
|
|
||
| fn main() { | ||
| let merged_dir = path("merged"); | ||
| let parts_out_dir = path("parts"); | ||
| let lib_dir = path("lib"); | ||
| let out_dir = path("out"); | ||
|
|
||
| rustc().input("quebec.rs").crate_name("quebec").crate_type("rlib").run(); | ||
| rustdoc() | ||
| .input("quebec.rs") | ||
| .crate_name("quebec") | ||
| .out_dir(&out_dir) | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir={}", parts_out_dir.display())) | ||
| .run(); | ||
| assert!(parts_out_dir.join("quebec.json").exists()); | ||
|
|
||
| rustc() | ||
| .input("tango.rs") | ||
| .crate_name("tango") | ||
| .crate_type("rlib") | ||
| .extern_("quebec", rust_lib_name("quebec")) | ||
| .run(); | ||
| rustdoc() | ||
| .input("tango.rs") | ||
| .crate_name("tango") | ||
| .extern_("quebec", rust_lib_name("quebec")) | ||
| .out_dir(&out_dir) | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir={}", parts_out_dir.display())) | ||
| .run(); | ||
| assert!(parts_out_dir.join("tango.json").exists()); | ||
|
|
||
| rustdoc() | ||
| .input("sierra.rs") | ||
| .crate_name("sierra") | ||
| .extern_("tango", rust_lib_name("tango")) | ||
| .library_search_path(cwd()) | ||
| .out_dir(&out_dir) | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir={}", parts_out_dir.display())) | ||
| .run(); | ||
| assert!(parts_out_dir.join("sierra.json").exists()); | ||
|
|
||
| let output = rustdoc() | ||
| .arg("-Zunstable-options") | ||
| .out_dir(&out_dir) | ||
| .arg(format!("--read-doc-meta-dir={}", parts_out_dir.display())) | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
| output.assert_stderr_not_contains("error: the compiler unexpectedly panicked. this is a bug."); | ||
|
|
||
| htmldocck().arg(&out_dir).arg("tango.rs").run(); | ||
| htmldocck().arg(&out_dir).arg("quebec.rs").run(); | ||
| htmldocck().arg(&out_dir).arg("sierra.rs").run(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| //@ needs-target-std | ||
|
|
||
| use run_make_support::{cwd, htmldocck, path, rust_lib_name, rustc, rustdoc}; | ||
|
|
||
| fn main() { | ||
| let merged_dir = path("merged"); | ||
| let parts_out_dir = path("parts"); | ||
| let lib_dir = path("lib"); | ||
| let out_dir = path("out"); | ||
|
|
||
| rustc().input("quebec.rs").crate_name("quebec").crate_type("rlib").run(); | ||
| rustdoc() | ||
| .input("quebec.rs") | ||
| .crate_name("quebec") | ||
| .out_dir("quebec-out") | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir=info/doc.parts/quebec")) | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
|
|
||
| rustc() | ||
| .input("tango.rs") | ||
| .crate_name("tango") | ||
| .crate_type("rlib") | ||
| .extern_("quebec", rust_lib_name("quebec")) | ||
| .run(); | ||
| rustdoc() | ||
| .input("tango.rs") | ||
| .crate_name("tango") | ||
| .extern_("quebec", rust_lib_name("quebec")) | ||
| .out_dir("tango-out") | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir=info/doc.parts/tango")) | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
|
|
||
| rustc() | ||
| .input("sierra.rs") | ||
| .crate_name("sierra") | ||
| .crate_type("rlib") | ||
| .extern_("tango", rust_lib_name("tango")) | ||
| .library_search_path(cwd()) | ||
| .run(); | ||
| rustdoc() | ||
| .input("sierra.rs") | ||
| .crate_name("sierra") | ||
| .extern_("tango", rust_lib_name("tango")) | ||
| .library_search_path(cwd()) | ||
| .out_dir("sierra-out") | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir=info/doc.parts/sierra")) | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
|
|
||
| rustc() | ||
| .input("romeo.rs") | ||
| .crate_name("romeo") | ||
| .crate_type("rlib") | ||
| .extern_("sierra", rust_lib_name("sierra")) | ||
| .library_search_path(cwd()) | ||
| .run(); | ||
| rustdoc() | ||
| .input("romeo.rs") | ||
| .crate_name("romeo") | ||
| .extern_("sierra", rust_lib_name("sierra")) | ||
| .library_search_path(cwd()) | ||
| .out_dir("romeo-out") | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir=info/doc.parts/romeo")) | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
|
|
||
| rustdoc() | ||
| .input("indigo.rs") | ||
| .crate_name("indigo") | ||
| .out_dir(&out_dir) | ||
| .arg("-Zunstable-options") | ||
| .arg(format!("--write-doc-meta-dir=info/doc.parts/indigo")) | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
|
|
||
| let output = rustdoc() | ||
| .arg("-Zunstable-options") | ||
| .out_dir(&out_dir) | ||
| .arg("--read-doc-meta-dir=info/doc.parts/tango") | ||
| .arg("--read-doc-meta-dir=info/doc.parts/romeo") | ||
| .arg("--read-doc-meta-dir=info/doc.parts/quebec") | ||
| .arg("--read-doc-meta-dir=info/doc.parts/sierra") | ||
| .arg("--read-doc-meta-dir=info/doc.parts/indigo") | ||
| .arg("--enable-index-page") | ||
| .run(); | ||
| output.assert_stderr_not_contains("error: the compiler unexpectedly panicked. this is a bug."); | ||
|
|
||
| htmldocck().arg(&out_dir).arg("tango.rs").run(); | ||
| htmldocck().arg(&out_dir).arg("quebec.rs").run(); | ||
| htmldocck().arg(&out_dir).arg("sierra.rs").run(); | ||
| htmldocck().arg(&out_dir).arg("indigo.rs").run(); | ||
| htmldocck().arg(&out_dir).arg("romeo.rs").run(); | ||
|
Comment on lines
+94
to
+98
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless I'm mistaken, it doesn't seem like there are any actual htmldocck |
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
View changes since the review