Skip to content

Commit

Permalink
Merge pull request #230 from jyn514/html-root-url
Browse files Browse the repository at this point in the history
Don't recommend setting html_root_url
  • Loading branch information
Manishearth authored Aug 5, 2021
2 parents 62f82d1 + 4fd7076 commit ac63584
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
1 change: 0 additions & 1 deletion src/checklist.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -208,51 +208,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

0 comments on commit ac63584

Please sign in to comment.