Skip to content
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

Add index page argument #54543

Merged
merged 6 commits into from
Nov 2, 2018
Merged

Conversation

GuillaumeGomez
Copy link
Member

@Mark-Simulacrum: I might need some help from you: in bootstrap, I want to add an argument (a new flag added into rustdoc) in order to generate the current index directly when rustdoc is documenting the std lib. However, my change in bootstrap didn't do it and I assume it must be moved inside the Std struct. But there, I don't see how to pass it to rustdoc through cargo. Did I miss anything?

r? @QuietMisdreavus

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 24, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:44:23] travis_fold:end:stage2-rustdoc

[00:44:23] travis_time:end:stage2-rustdoc:start=1537833488550055619,finish=1537833488826169518,duration=276113899

[00:44:23] error: option `--index-page` argument must be a file
[00:44:23] 
[00:44:23] 
[00:44:23] 
[00:44:23] command did not execute successfully: "/checkout/obj/build/bootstrap/debug/rustdoc" "--html-after-content" "/checkout/src/doc/footer.inc" "--html-before-content" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc/version_info.html" "--html-in-header" "/checkout/src/doc/favicon.inc" "--index-page" "src/doc/index.md" "--markdown-playground-url" "https://play.rust-lang.org/" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc" "/checkout/src/doc/rust.md" "--markdown-css" "rust.css"
[00:44:23] 
[00:44:23] 
[00:44:23] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[00:44:23] Build completed unsuccessfully in 0:04:09
[00:44:23] Build completed unsuccessfully in 0:04:09
[00:44:23] make: *** [all] Error 1
[00:44:23] Makefile:28: recipe for target 'all' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0c2763fc
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
149112 ./src/llvm-emscripten/test
148852 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc
148580 ./obj/build/bootstrap/debug/incremental
134140 ./obj/build/bootstrap/debug/incremental/bootstrap-2zc4gzhr0d54q
134136 ./obj/build/bootstrap/debug/incremental/bootstrap-2zc4gzhr0d54q/s-f545tnz7cs-y11ee0-3093t8bfyy2gb

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GuillaumeGomez
Copy link
Member Author

@Mark-Simulacrum Need help when you have a bit of time. I tried to pass the index-page flag to cargo but I had to replace doc with rustdoc, however it doesn't work at all like this. Did I miss anything obvious?

@Mark-Simulacrum
Copy link
Member

Yes, I plan to take a look at this tomorrow I hope, probably won't get a chance to tonight.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:48:53]     Checking compiler_builtins v0.0.0 (file:///checkout/src/rustc/compiler_builtins_shim)
[00:48:55]  Documenting alloc v0.0.0 (file:///checkout/src/liballoc)
[00:48:55] thread 'main' panicked at '
[00:48:55] 
[00:48:55] failed to run "/path/to/nowhere/rustdoc/not/required" "--crate-name" "alloc" "liballoc/lib.rs" "--target" "x86_64-unknown-linux-gnu" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/doc" "index-page" "/checkout/src/doc/index.md" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps" "-L" "dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps" "--extern" "compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-66b9d646ca55a4f6.rmeta" "--extern" "core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-dfbcb38dfdb6370a.rmeta" "--cfg" "stage1" "--cfg" "dox" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1" "-Z" "force-unstable-if-unmarked" "-Z" "unstable-options" "--crate-version" "1.30.0-dev": No such file or directory (os error 2)
[00:48:55] ', bootstrap/bin/rustdoc.rs:79:19
[00:48:55] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:48:55] error: Could not document `alloc`.
[00:48:55] 
[00:48:55] 
[00:48:55] Caused by:
[00:48:55]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --crate-name alloc liballoc/lib.rs --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/doc index-page /checkout/src/doc/index.md -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/release/deps --extern compiler_builtins=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcompiler_builtins-66b9d646ca55a4f6.rmeta --extern core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/deps/libcore-dfbcb38dfdb6370a.rmeta` (exit code: 101)
[00:48:55] 
[00:48:55] 
[00:48:55] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "rustdoc" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-Z" "unstable-options" "-p" "alloc" "--" "index-page" "/checkout/src/doc/index.md"
[00:48:55] 
[00:48:55] 
[00:48:55] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap doc
[00:48:55] Build completed unsuccessfully in 0:05:22
[00:48:55] Build completed unsuccessfully in 0:05:22
[00:48:55] Makefile:28: recipe for target 'all' failed
[00:48:55] make: *** [all] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0df531d4
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:020afff3:start=1537914330481632417,finish=1537914330487494212,duration=5861795
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0f542d87
$ ln -s . checkout && for CORE in obj/cores/

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@GuillaumeGomez GuillaumeGomez changed the title [WIP] Add index page argument Add index page argument Sep 29, 2018
@GuillaumeGomez
Copy link
Member Author

It's now ready!

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a screenshot of what the index page looks like if you don't provide the --index-page argument?

Can you update the Rustdoc Book with the new CLI flags you added?

src/librustdoc/html/render.rs Show resolved Hide resolved
@GuillaumeGomez
Copy link
Member Author

Yes and yes.

@GuillaumeGomez
Copy link
Member Author

@QuietMisdreavus What remains to be done here btw? The books are generated with the index page directly (since it's not *really* running rustdoc, seems weird to use this new flag for them).

@QuietMisdreavus
Copy link
Member

QuietMisdreavus commented Oct 10, 2018

Do you have a screenshot of what the index page looks like if you don't provide the --index-page argument?

Can you update the Rustdoc Book with the new CLI flags you added?

I don't see an update to either of these?

EDIT: When i say "update the Rustdoc Book", i mean "write new docs for the book talking about the new flags".

@GuillaumeGomez
Copy link
Member Author

EDIT: When i say "update the Rustdoc Book", i mean "write new docs for the book talking about the new flags".

Now I get it!

What remains to be done (reminder for me):

  • Add entry about this feature in the rustdoc book
  • Add a screenshot of the default index page

@GuillaumeGomez
Copy link
Member Author

So here is the default index page generated (yes I generated a lot of crates locally :-.):

screen shot 2018-10-13 at 14 31 56

@GuillaumeGomez
Copy link
Member Author

Updated.

@GuillaumeGomez
Copy link
Member Author

@QuietMisdreavus Anything else?

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the CLI flag enable-index-page, but the Context field disable_index_page? It creates confusion when looking through the code if the CLI flag is the opposite of how the code looks at it.

(GitHub just released the ability for us to suggest code changes as a potential patch, so i'm going to test it out here, haha!)

@@ -106,6 +109,8 @@ struct Context {
/// The map used to ensure all generated 'id=' attributes are unique.
id_map: Rc<RefCell<IdMap>>,
pub shared: Arc<SharedContext>,
pub disable_index_page: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub disable_index_page: bool,
pub enable_index_page: bool,

@@ -501,7 +506,12 @@ pub fn run(mut krate: clean::Crate,
sort_modules_alphabetically: bool,
themes: Vec<PathBuf>,
enable_minification: bool,
id_map: IdMap) -> Result<(), Error> {
id_map: IdMap,
disable_index_page: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disable_index_page: bool,
enable_index_page: bool,

@@ -572,6 +582,8 @@ pub fn run(mut krate: clean::Crate,
codes: ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build()),
id_map: Rc::new(RefCell::new(id_map)),
shared: Arc::new(scx),
disable_index_page,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
disable_index_page,
enable_index_page,

@@ -969,6 +990,42 @@ themePicker.onblur = handleThemeButtonsBlur;
}
try_err!(writeln!(&mut w, "initSearch(searchIndex);"), &dst);

if cx.disable_index_page == false {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if cx.disable_index_page == false {
if cx.enable_index_page {

@@ -580,7 +599,10 @@ fn main_args(args: &[String]) -> isize {
renderinfo,
sort_modules_alphabetically,
themes,
enable_minification, id_map)
enable_minification, id_map,
!enable_index_page, index_page,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
!enable_index_page, index_page,
enable_index_page, index_page,

@QuietMisdreavus
Copy link
Member

Oh one more thing: Can you add a test? It should just work with the regular rustdoc tests if you add an auxiliary crate to the build.

@GuillaumeGomez
Copy link
Member Author

Updated.

@@ -389,3 +389,16 @@ pub struct BigX;

Then, when looking for it through the `rustdoc` search, if you enter "x" or
"big", search will show the `BigX` struct first.

### `index-page` feature
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are CLI flags, they should follow the convention of the other flags' headings:

### `--index-page`: provide a top-level landing page for docs

### `--enable-index-page`: generate a default index page for docs

(The section about doc_alias is also in the wrong place, but i failed to catch that when you wrote it in the first place... >_>)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. I'll fix all that at once then.

@GuillaumeGomez
Copy link
Member Author

Updated.

Copy link
Member

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much!

@QuietMisdreavus
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Nov 2, 2018

📌 Commit 2b64605 has been approved by QuietMisdreavus

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 2, 2018
@bors
Copy link
Contributor

bors commented Nov 2, 2018

⌛ Testing commit 2b64605 with merge e53a5ff...

bors added a commit that referenced this pull request Nov 2, 2018
Add index page argument

@Mark-Simulacrum: I might need some help from you: in bootstrap, I want to add an argument (a new flag added into `rustdoc`) in order to generate the current index directly when `rustdoc` is documenting the `std` lib. However, my change in `bootstrap` didn't do it and I assume it must be moved inside the `Std` struct. But there, I don't see how to pass it to `rustdoc` through `cargo`. Did I miss anything?

r? @QuietMisdreavus
@bors
Copy link
Contributor

bors commented Nov 2, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: QuietMisdreavus
Pushing e53a5ff to master...

@bors bors merged commit 2b64605 into rust-lang:master Nov 2, 2018
@GuillaumeGomez GuillaumeGomez deleted the top-level-index branch November 2, 2018 22:25
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 16, 2020
…acrum

Use local links in the alloc docs.

Links to other crates (like core) from the alloc crate were incorrectly using the `https://doc.rust-lang.org/nightly/` absolute (remote) links, instead of relative (local) links.  For example, the link to `Result` at https://doc.rust-lang.org/1.44.1/alloc/vec/struct.Vec.html#method.try_reserve goes to /nightly/.

This is because alloc was being documented before core, and rustdoc relies on the existence of the local directory to know if it should use a local or remote link.

There was code that tried to compensate for this (`create_dir_all`), but in rust-lang#54543 it was broken because instead of running `cargo doc` once for all the crates, it was changed to run `cargo rustdoc` for each crate individually. This means that `create_dir_all` was no longer doing what it was supposed to be doing (creating all the directories before starting).

The solution here is to just build in the correct order (from the dependency leaves towards the root).  An alternate solution would be to switch back to running `cargo doc` once (and use RUSTDOCFLAGS for passing in flags).  Another alternate solution would be to iterate over the list twice, creating the directories during the first pass.

I also did a little cleanup to remove the "crate-docs" directory. This was added in the past because different crates were built in different directories. Over time, things have been unified (and rustc docs no longer include std), so it is no longer necessary.
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 16, 2020
…acrum

Use local links in the alloc docs.

Links to other crates (like core) from the alloc crate were incorrectly using the `https://doc.rust-lang.org/nightly/` absolute (remote) links, instead of relative (local) links.  For example, the link to `Result` at https://doc.rust-lang.org/1.44.1/alloc/vec/struct.Vec.html#method.try_reserve goes to /nightly/.

This is because alloc was being documented before core, and rustdoc relies on the existence of the local directory to know if it should use a local or remote link.

There was code that tried to compensate for this (`create_dir_all`), but in rust-lang#54543 it was broken because instead of running `cargo doc` once for all the crates, it was changed to run `cargo rustdoc` for each crate individually. This means that `create_dir_all` was no longer doing what it was supposed to be doing (creating all the directories before starting).

The solution here is to just build in the correct order (from the dependency leaves towards the root).  An alternate solution would be to switch back to running `cargo doc` once (and use RUSTDOCFLAGS for passing in flags).  Another alternate solution would be to iterate over the list twice, creating the directories during the first pass.

I also did a little cleanup to remove the "crate-docs" directory. This was added in the past because different crates were built in different directories. Over time, things have been unified (and rustc docs no longer include std), so it is no longer necessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants