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

Don't recommend setting html_root_url #230

Merged
merged 1 commit into from Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion src/checklist.md
Expand Up @@ -36,7 +36,6 @@
- [ ] Cargo.toml includes all common metadata ([C-METADATA])
- authors, description, license, homepage, documentation, repository,
readme, keywords, categories
- [ ] Crate sets html_root_url attribute "https://docs.rs/CRATE/X.Y.Z" ([C-HTML-ROOT])
- [ ] Release notes document all significant changes ([C-RELNOTES])
- [ ] Rustdoc does not show unhelpful implementation details ([C-HIDDEN])
- **Predictability** *(crate enables legible code that acts how it looks)*
Expand Down
45 changes: 0 additions & 45 deletions src/documentation.md
Expand Up @@ -202,51 +202,6 @@ crate other than the source repository or API documentation. Do not make
`homepage` redundant with either the `documentation` or `repository` values. For
example, serde sets `homepage` to *https://serde.rs*, a dedicated website.

[C-HTML-ROOT]: #c-html-root
<a id="c-html-root"></a>
### Crate sets html_root_url attribute (C-HTML-ROOT)

<!--
Remove this guideline once rustdoc links no-deps documentation with no
html_root_url to docs.rs by default.
https://github.com/rust-lang/rust/issues/42301
-->

It should point to `"https://docs.rs/CRATE/MAJOR.MINOR.PATCH"`,
assuming the crate uses docs.rs for its primary API documentation.

The `html_root_url` attribute tells rustdoc how to create URLs to
items in the crate when compiling downstream crates. Without it, links
in the documentation of crates that depend on your crate will be
incorrect.

```rust
#![doc(html_root_url = "https://docs.rs/log/0.3.8")]
```

Because this URL contains an exact version number, it must be kept in
sync with the version number in `Cargo.toml`. The [`version-sync`]
crate can help with this by letting you add an integration test that
fails if the `html_root_url` version number is out of sync with the
crate version.

[`version-sync`]: https://crates.io/crates/version-sync

If you do not like that mechanism, it is recommended to add a comment
to the `Cargo.toml` version key reminding yourself to keep the two
updated together, like:

```toml
version = "0.3.8" # remember to update html_root_url
```

For documentation hosted outside of docs.rs, the value for `html_root_url` is
correct if appending the crate name + index.html takes you to the documentation
of the crate's root module. For example if the documentation of the root module
is located at `"https://api.rocket.rs/rocket/index.html"` then the
`html_root_url` would be `"https://api.rocket.rs"`.


<a id="c-relnotes"></a>
## Release notes document all significant changes (C-RELNOTES)

Expand Down