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

[rustdoc] Generate redirect map file #81223

Merged
merged 4 commits into from
Mar 3, 2021

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Jan 20, 2021

Fixes #81134.

So with this code:

#![crate_name = "foo"]

pub use private::Quz;
pub use hidden::Bar;

mod private {
    pub struct Quz;
}

#[doc(hidden)]
pub mod hidden {
    pub struct Bar;
}

#[macro_export]
macro_rules! foo {
() => {}
}

It generates:

{
  "foo/macro.foo!.html": "foo/macro.foo.html",
  "foo/private/struct.Quz.html": "foo/struct.Quz.html",
  "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
}

Do the pathes look as you expected @pietroalbini?

r? @jyn514

@GuillaumeGomez GuillaumeGomez added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 20, 2021
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 20, 2021
@rust-log-analyzer

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented Jan 21, 2021

The implementation looks mostly fine to me, but I'm not 100% convinced this is necessary - @pietroalbini the main issue in #81134 was that rustdoc is generating inline <script>s, right? I think we could just remove that and be fine, since there's also a <meta http-equiv="refresh">.

@pietroalbini
Copy link
Member

pietroalbini commented Jan 21, 2021

It generates:

{
    "macro.foo!.html":"macro.foo.html",
    "doc/foo/private/struct.Quz.html":"../../foo/struct.Quz.html",
    "doc/foo/hidden/struct.Bar.html":"../../foo/struct.Bar.html"
}

Do the pathes look as you expected @pietroalbini?

@GuillaumeGomez I have some bits of feedback:

  • macro.foo!.html should be foo/macro.foo!.html.
  • The doc/ prefix shouldn't be there: if you call rustdoc -o otheroutputdir ... I guess the code would include otheroutputdir in the redirect map instead of doc, which I'm not sure is right.
  • I guess relative paths as the destination are ok, but I think it would make more sense to avoid ../s and make all the redirects relative from the documentation root.

the main issue in #81134 was that rustdoc is generating inline <script>s, right? I think we could just remove that and be fine, since there's also a <meta http-equiv="refresh">.

@jyn514 technically yes, but even the <meta http-equiv="refresh"> provides a worse UX than server-side redirects. It's inevitable when using a simple static server or loading docs from the filesystem, but an application like docs.rs can use a feature like this to greatly improve the redirect UX.

@bors
Copy link
Contributor

bors commented Jan 21, 2021

☔ The latest upstream changes (presumably #81240) made this pull request unmergeable. Please resolve the merge conflicts.

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 21, 2021
@rust-log-analyzer

This comment has been minimized.

@pietroalbini
Copy link
Member

The output you posted on the PR body looks good @GuillaumeGomez, but there should be a test for it.

@GuillaumeGomez
Copy link
Member Author

I'm waiting for #81197 to add a run-make test.

@bors
Copy link
Contributor

bors commented Jan 27, 2021

☔ The latest upstream changes (presumably #80987) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 14, 2021
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

I'm waiting for #81197 to add a run-make test.

@Mark-Simulacrum asked that I drop that change from the PR, so I would just make it run-make-fulldeps for now.

src/librustdoc/html/render/mod.rs Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Feb 15, 2021

Also, please remember to update the labels so it's easy to tell the state of the PR. I didn't realize you thought this was blocked.

@GuillaumeGomez
Copy link
Member Author

I added the run-make-fulldeps test. I had to add a lot of print in there to know what I did wrong and I decided to keep them in case they're needed in the future. That was a fun ride!

@GuillaumeGomez GuillaumeGomez added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 15, 2021
@GuillaumeGomez
Copy link
Member Author

@jyn514 Thanks a lot for your great catch! I fixed it.

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

This looks good to me (with nits fixed), at least good enough to be on nightly. @pietroalbini may want to take another look before this is merged though.

src/librustdoc/html/render/mod.rs Outdated Show resolved Hide resolved
src/librustdoc/html/render/mod.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 removed their assignment Feb 23, 2021
@jyn514 jyn514 added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 23, 2021
@GuillaumeGomez
Copy link
Member Author

Updated! Waiting for @pietroalbini now. :)

@pietroalbini
Copy link
Member

The format looks good on my end!

@jyn514
Copy link
Member

jyn514 commented Mar 2, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Mar 2, 2021

📌 Commit 41fc58b has been approved by jyn514

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 2, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Mar 2, 2021
…p, r=jyn514

[rustdoc] Generate redirect map file

Fixes rust-lang#81134.

So with this code:

```rust
#![crate_name = "foo"]

pub use private::Quz;
pub use hidden::Bar;

mod private {
    pub struct Quz;
}

#[doc(hidden)]
pub mod hidden {
    pub struct Bar;
}

#[macro_export]
macro_rules! foo {
() => {}
}
```

It generates:

```json
{
  "foo/macro.foo!.html": "foo/macro.foo.html",
  "foo/private/struct.Quz.html": "foo/struct.Quz.html",
  "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
}
```

Do the pathes look as you expected `@pietroalbini?`

r? `@jyn514`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 2, 2021
…p, r=jyn514

[rustdoc] Generate redirect map file

Fixes rust-lang#81134.

So with this code:

```rust
#![crate_name = "foo"]

pub use private::Quz;
pub use hidden::Bar;

mod private {
    pub struct Quz;
}

#[doc(hidden)]
pub mod hidden {
    pub struct Bar;
}

#[macro_export]
macro_rules! foo {
() => {}
}
```

It generates:

```json
{
  "foo/macro.foo!.html": "foo/macro.foo.html",
  "foo/private/struct.Quz.html": "foo/struct.Quz.html",
  "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
}
```

Do the pathes look as you expected ``@pietroalbini?``

r? ``@jyn514``
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Mar 3, 2021
…p, r=jyn514

[rustdoc] Generate redirect map file

Fixes rust-lang#81134.

So with this code:

```rust
#![crate_name = "foo"]

pub use private::Quz;
pub use hidden::Bar;

mod private {
    pub struct Quz;
}

#[doc(hidden)]
pub mod hidden {
    pub struct Bar;
}

#[macro_export]
macro_rules! foo {
() => {}
}
```

It generates:

```json
{
  "foo/macro.foo!.html": "foo/macro.foo.html",
  "foo/private/struct.Quz.html": "foo/struct.Quz.html",
  "foo/hidden/struct.Bar.html": "foo/struct.Bar.html"
}
```

Do the pathes look as you expected ```@pietroalbini?```

r? ```@jyn514```
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 3, 2021
Rollup of 10 pull requests

Successful merges:

 - rust-lang#81223 ([rustdoc] Generate redirect map file)
 - rust-lang#82439 (BTree: fix untrue safety)
 - rust-lang#82469 (Use a crate to produce rustdoc tree comparisons instead of the `diff` command)
 - rust-lang#82589 (unix: Non-mutable bufs in send_vectored_with_ancillary_to)
 - rust-lang#82689 (meta: Notify Zulip for rustdoc nominated issues)
 - rust-lang#82695 (Revert non-power-of-two vector restriction)
 - rust-lang#82706 (use outer_expn_data() instead of outer_expn().expn_data())
 - rust-lang#82710 (FloatToInit: Replacing round_unchecked_to --> to_int_unchecked)
 - rust-lang#82712 (Remove unnecessary conditional `cfg(target_os)` for `redox` and `vxworks`)
 - rust-lang#82713 (Update cargo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9a827d9 into rust-lang:master Mar 3, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 3, 2021
@GuillaumeGomez GuillaumeGomez deleted the generate-redirect-map branch March 3, 2021 11:24
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. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a flag to generate a redirect map in rustdoc
8 participants