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

Use semver compatible links to dependencies #1055

Open
Nemo157 opened this issue Sep 18, 2020 · 2 comments
Open

Use semver compatible links to dependencies #1055

Nemo157 opened this issue Sep 18, 2020 · 2 comments
Labels
A-builds Area: Building the documentation for a crate C-enhancement Category: This is a new feature S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Sep 18, 2020

Currently when we build documentation we pass a flag like --extern-html-root-url foobar=https://docs.rs/foobar/1.0.0 for each dependency with the exact version of the dependency used. This means if the dependency releases a new version compatible with the version constraint, all the links to it from the dependent crate will still go to the old version.

To avoid this we could pass semver-constraint urls like --extern-html-root-url foobar=https://docs.rs/foobar/^1.0.0 (based on the actual constraint specified), then links will automatically go to the latest compatible version of the docs.


The biggest blocker to doing so is getting guarantees from Rustdoc that intra-doc-links generated for one version of a crate will still be valid in all semver-compatible later versions of the crate. A couple of issues currently cause this to not be true:

  1. The exact kind of a type is part of the url, so while e.g. changing a struct to an enum is a non-breaking change to code, it will result in a link to the item becoming a 404 (Use name.namespace.html as the canonical URL, not kind.name.html rust#55160)
  2. Re-exports don't exist in the file tree, as an example consider these two versions of a crate:
// Version 1.0.0
pub struct Foo;
// Version 1.0.1 - A semver compatible change to move the canonical location and leave a re-export behind
pub mod foo { pub struct Foo; }
pub use foo::Foo;

Looking at the filetree of the built docs we can see that a link to the old canonical location of foo/struct.Foo.html will be a 404 in the new version:

target/doc/foo
├── all.html
├── index.html
├── sidebar-items.js
└── struct.Foo.html

target/doc/foo
├── all.html
├── foo
│   ├── index.html
│   ├── sidebar-items.js
│   └── struct.Foo.html
├── index.html
└── sidebar-items.js

(There may be more issues, these are just what was linked to me by @jyn514 and the first thought I had of what might go wrong. The first step of actually working on this if it's worth it would be identifying all the potential issues and working out whether it's possible/worthwhile trying to get this guarantee out of Rustdoc).

@jyn514 jyn514 added A-builds Area: Building the documentation for a crate C-enhancement Category: This is a new feature S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work. labels Sep 18, 2020
@jyn514
Copy link
Member

jyn514 commented Sep 20, 2020

I posted an RFC for the rustdoc side of this: rust-lang/rfcs#2988

@jyn514
Copy link
Member

jyn514 commented Nov 24, 2020

Since #1188 this will also require changes to rustdoc-map to allow semver versions in the links.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-builds Area: Building the documentation for a crate C-enhancement Category: This is a new feature S-blocked Status: marked as blocked ❌ on something else such as an RFC or other implementation work.
Projects
None yet
Development

No branches or pull requests

2 participants