Skip to content

Commit b0e09df

Browse files
committed
Explain C-HTML-ROOT. Fixes #75
1 parent 702d186 commit b0e09df

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

README.md

+30-10
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ Guidelines use active voice.
104104
- [ ] Cargo.toml includes all common metadata ([C-METADATA])
105105
- authors, description, license, homepage, documentation, repository,
106106
readme, keywords, categories
107-
- [ ] Crate sets html_root_url attribute "https://docs.rs/$crate/$version" ([C-HTML-ROOT])
108107
- [ ] Cargo.toml documentation key points to "https://docs.rs/$crate" ([C-DOCS-RS])
108+
- [ ] Crate sets html_root_url attribute "https://docs.rs/$crate/$version" ([C-HTML-ROOT])
109109
- [ ] Release notes document all significant changes ([C-RELNOTES])
110110
- **Predictability** *(crate enables legible code that acts how it looks)*
111111
- [ ] Smart pointers do not add inherent methods ([C-SMART-PTR])
@@ -1050,15 +1050,6 @@ all the things"].
10501050
- `keywords`
10511051
- `categories`
10521052

1053-
[C-HTML-ROOT]: #c-html-root
1054-
<a id="c-html-root"></a>
1055-
### Crate sets html_root_url attribute (C-HTML-ROOT)
1056-
1057-
It should point to `"https://docs.rs/$crate/$version"`.
1058-
1059-
Cargo.toml should contain a note next to the version to remember to bump the
1060-
`html_root_url` when bumping the crate version.
1061-
10621053
[C-DOCS-RS]: #c-docs-rs
10631054
<a id="c-docs-rs"></a>
10641055
### Cargo.toml documentation key points to docs.rs (C-DOCS-RS)
@@ -1078,6 +1069,35 @@ but should be considered carefully.
10781069

10791070
[docs.rs]: https://docs.rs
10801071

1072+
[C-HTML-ROOT]: #c-html-root
1073+
<a id="c-html-root"></a>
1074+
### Crate sets html_root_url attribute (C-HTML-ROOT)
1075+
1076+
It should point to `"https://docs.rs/$crate/$version"`, assuming the crate
1077+
uses docs.rs for it's primary API documentation.
1078+
1079+
The `html_root_url` attribute tells rustdoc how to create URLs to
1080+
items in the crate when compiling downstream crates. Without it, links
1081+
in the documentation of crates that depend on your crate will be
1082+
incorrect.
1083+
1084+
It generally looks something like:
1085+
1086+
```rust
1087+
#![doc(html_root_url = "https://docs.rs/log/0.3.8")]
1088+
```
1089+
1090+
Because this URL contains an exact version number, it must be kept in
1091+
sync with the version number in `Cargo.toml`. Unfortunately there is
1092+
no mechanism in Rust today to eliminate this duplication, so
1093+
the current recommendation is to add a comment to the `Cargo.toml`
1094+
version key reminding yourself to keep the two updated together,
1095+
like:
1096+
1097+
```toml
1098+
version = "0.3.8" # remember to update html_root_url
1099+
```
1100+
10811101
[C-RELNOTES]: #c-relnotes
10821102
<a id="c-relnotes"></a>
10831103
### Release notes document all significant changes (C-RELNOTES)

0 commit comments

Comments
 (0)