[rustdoc] Add new --book-location option to add a link to associated guide and generate it if local#139769
[rustdoc] Add new --book-location option to add a link to associated guide and generate it if local#139769GuillaumeGomez wants to merge 6 commits intorust-lang:mainfrom
--book-location option to add a link to associated guide and generate it if local#139769Conversation
|
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @jsha |
This comment has been minimized.
This comment has been minimized.
15e7374 to
1aefb85
Compare
This comment has been minimized.
This comment has been minimized.
1aefb85 to
bcb5ed2
Compare
This comment has been minimized.
This comment has been minimized.
bcb5ed2 to
cad5667
Compare
|
The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging. |
This comment has been minimized.
This comment has been minimized.
cad5667 to
3388b0b
Compare
|
This PR modifies cc @jieyouxu |
|
Finally fixed all tidy errors. :') |
src/librustdoc/config.rs
Outdated
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| pub(crate) enum PathOrURL { |
There was a problem hiding this comment.
| pub(crate) enum PathOrURL { | |
| pub(crate) enum PathOrUrl { |
to follow idiom, and to be consistent with the style in this crate
|
☔ The latest upstream changes (presumably #140336) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Whoops, missed this in my notifications, sorry 😅
Any reason you're making it insta-stable? Seems like might as well go through the normal process of adding as an unstable flag first. |
It was already unstable. 😄 |
| "", | ||
| ), | ||
| opt( | ||
| Unstable, |
There was a problem hiding this comment.
@camelid: Just checked and the option is indeed unstable. 😉
There was a problem hiding this comment.
Ah, I was just confused because you said it'd need an FCP, which I thought we only required for stabilizations.
There was a problem hiding this comment.
Hum, well it's a big change in rustdoc (as is, scope expansion), so better be sure everyone agrees with this direction.
camelid
left a comment
There was a problem hiding this comment.
Looks good overall, but left some comments.
src/librustdoc/config.rs
Outdated
| #[derive(Clone, Debug)] | ||
| pub(crate) enum PathOrURL { | ||
| Path(PathBuf), | ||
| URL(String), |
There was a problem hiding this comment.
Ditto here with tshepang's suggestion from above.
| "", | ||
| ), | ||
| opt( | ||
| Unstable, |
There was a problem hiding this comment.
Ah, I was just confused because you said it'd need an FCP, which I thought we only required for stabilizations.
src/librustdoc/lib.rs
Outdated
| Err(error) => return Err(format!("failed to load book: {error:?}")), | ||
| }; | ||
| let output_dir = render_options.output.join("doc-book"); | ||
| *book_dir = output_dir.join("index.html"); |
There was a problem hiding this comment.
I don't like that this mutates the render_options.book_location to record the new path of the book. I think it'd better to have two separate fields, one for the source location of the book and one for the target location (None if the source was a URL).
There was a problem hiding this comment.
Not sure to agree but not something I think is worth debating about so let's go. However: I'm gonna use PathOrUrl because otherwise you'd need to use two types to get the information, which is suboptimal imo.
| "Apache-2.0", | ||
| "Apache-2.0/MIT", | ||
| "BSD-2-Clause OR Apache-2.0 OR MIT", // zerocopy | ||
| "CC0-1.0", // notify |
There was a problem hiding this comment.
Who's responsible for this license exceptions list? Feels like it'd be good to check that these exceptions are OK with someone who's more experienced in this area.
There was a problem hiding this comment.
I know the right person for this. cc @wesleywiser :)
| @@ -0,0 +1,7 @@ | |||
| //@ compile-flags: -Zunstable-options --book-location https://somewhere.world | |||
There was a problem hiding this comment.
We should have another (run-make) test that tests the mdbook integration, especially since that's where most of the complexity of this PR is.
There was a problem hiding this comment.
What do you want to test exactly?
| ## Generating link to guide | ||
|
|
||
| You can generate a link to a guide or generate the guide with `mdbook` using the `--book-location` | ||
| command line argument. It accepts either a URL or a path. If a path is provided, the book will | ||
| be generated. |
There was a problem hiding this comment.
| ## Generating link to guide | |
| You can generate a link to a guide or generate the guide with `mdbook` using the `--book-location` | |
| command line argument. It accepts either a URL or a path. If a path is provided, the book will | |
| be generated. | |
| ## Bundling or linking to a guide | |
| You can generate a link to a guide or bundle an `mdbook` guide using the `--book-location` | |
| command line argument. It accepts either a URL or a path. If a path is provided, the book will | |
| be built with `mdbook`. |
3388b0b to
d4fefe0
Compare
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #140726) made this pull request unmergeable. Please resolve the merge conflicts. |
7d007c9 to
eda5e44
Compare
|
Fixed merge conflict. |
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #140705) made this pull request unmergeable. Please resolve the merge conflicts. |
…e the target location
7e3df42 to
d0f941f
Compare
|
Fixed merge conflict. |
|
☔ The latest upstream changes (presumably #140895) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I think I'm gonna wait for the PR to be approved before fixing more merge conflicts. 😆 |
|
Oh neat, Bevy will use this once it's shipped. |
|
From discussion: remove the possibility to provide a URL, only allow a path (to ensure that once generated on docs.rs, versioning will always be valid). |
This comment was marked as outdated.
This comment was marked as outdated.
|
Oops, I just saw rust-lang/docs.rs#1293. If https://docs.rs can host |
|
It's path to file, not path to module. |
|
I'm not sure this feature has a plausible path to stability. mdBook occasionally releases breaking changes, has more breaking changes planned, does customization by directly replacing chunks of the HTML (which means every change to the DOM is breaking), and exposes fontawesome (which is on version 6.0) as part of its format. IMO, the Rustdoc side of this feature needs to have a stability story more like how incompatible versions of a single Cargo library can coexist. Instead of incorporating mdBook's API into our own, crate authors should be able to pin the mdBook version without pinning the entire Rust toolchain. A path like this one would also allow mdBook's stability story to be less extreme than Rust's and more like ammonia's: when 2.0 is released, 1.0 continues to receive security fixes, but no new features. Other doc hosts, like ReadTheDocs and arXiv, pin the old version of their docs toolchains for exactly this reason. |
|
@notriddle pinning doesn't sound too bad but maybe just having a minimal set of features would already help a lot? I think most books mainly need:
Basically what rusdoc already has. I personally find customization to be somewhat of an anti-feature - I want the docs to look consistent with rustdoc and not mess with it. |
|
@Kixunil I'm not sure if enough books would be satisfied with that to make it worth doing. That's the functionality that everybody uses, sure, but there's a "long tail" of features that, individually, most books don't need, but all together, most books need at least one thing that we don't have built-in. @alice-i-cecile I don't know if "bevy will use this" means migrating that examples page into mdBook1, but if it does, "20% functionality for 80% of books" won't cut it. There's a lot of stuff in there that mdBook doesn't do and won't add because most books don't need it. Other books also wind up implementing a bunch of their own, non-overlapping, functionality. TRPL has a custom graphic for non-compiling examples, comprehensive-rust has a custom gizmo for "speaker notes", and rust-by-example has a language picker. Some of those might be worth baking in, but all of them? Footnotes
|
|
Yeah, I don't expect Bevy will migrate to |
This option adds the possibility to provide a path or a URL to the associated guide of this crate in the crate-level doc page. If the provided argument is a path, then the guide is generated using the
mdbookcrate.It looks like this:
You can give it a try here.
It'll need an FCP before getting merged.
Also I need to add tests when the argument is a path but I'll wait for the feature form to be final before doing it to prevent doing it more than once. 😄
cc @notriddle
r? @camelid