Skip to content

Commit b36cc0d

Browse files
committed
Revert "Remove html_root_url guideline"
This reverts commit 5c457df.
1 parent 9b4a4d8 commit b36cc0d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/checklist.md

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
- [ ] Cargo.toml includes all common metadata ([C-METADATA])
3737
- authors, description, license, homepage, documentation, repository,
3838
readme, keywords, categories
39+
- [ ] Crate sets html_root_url attribute "https://docs.rs/CRATE/X.Y.Z" ([C-HTML-ROOT])
3940
- [ ] Release notes document all significant changes ([C-RELNOTES])
4041
- [ ] Rustdoc does not show unhelpful implementation details ([C-HIDDEN])
4142
- **Predictability** *(crate enables legible code that acts how it looks)*
@@ -102,6 +103,7 @@
102103
[C-FAILURE]: documentation.html#c-failure
103104
[C-LINK]: documentation.html#c-link
104105
[C-METADATA]: documentation.html#c-metadata
106+
[C-HTML-ROOT]: documentation.html#c-html-root
105107
[C-RELNOTES]: documentation.html#c-relnotes
106108
[C-HIDDEN]: documentation.html#c-hidden
107109

src/documentation.md

+32
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,38 @@ crate other than the source repository or API documentation. Do not make
206206
`homepage` redundant with either the `documentation` or `repository` values. For
207207
example, serde sets `homepage` to *https://serde.rs*, a dedicated website.
208208

209+
[C-HTML-ROOT]: #c-html-root
210+
<a id="c-html-root"></a>
211+
### Crate sets html_root_url attribute (C-HTML-ROOT)
212+
213+
It should point to `"https://docs.rs/CRATE/MAJOR.MINOR.PATCH"`,
214+
assuming the crate uses docs.rs for its primary API documentation.
215+
216+
The `html_root_url` attribute tells rustdoc how to create URLs to
217+
items in the crate when compiling downstream crates. Without it, links
218+
in the documentation of crates that depend on your crate will be
219+
incorrect.
220+
221+
```rust
222+
#![doc(html_root_url = "https://docs.rs/log/0.3.8")]
223+
```
224+
225+
Because this URL contains an exact version number, it must be kept in
226+
sync with the version number in `Cargo.toml`. The [`version-sync`]
227+
crate can help with this by letting you add an integration test that
228+
fails if the `html_root_url` version number is out of sync with the
229+
crate version.
230+
231+
[`version-sync`]: https://crates.io/crates/version-sync
232+
233+
If you do not like that mechanism, it is recommended to add a comment
234+
to the `Cargo.toml` version key reminding yourself to keep the two
235+
updated together, like:
236+
237+
```toml
238+
version = "0.3.8" # remember to update html_root_url
239+
```
240+
209241

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

0 commit comments

Comments
 (0)