-
Notifications
You must be signed in to change notification settings - Fork 819
Description
Feature Request
Crates
- all
Motivation
Currently, all tracing
crates use URL-based links for all RustDoc links, including internal links within the crate. However, switching to intra-RustDoc links has some advantages over URL-based links. In particular, we can now get a compiler warning (or error) when links are broken, using #[warn(intra_doc_link_resolution_failure)]
. This would help prevent issues like #935.
Proposal
Intra-RustDoc links are currently available on nightly only, although they are planned for stabilization in Rust 1.47. However, we already build docs on nightly on both docs.rs and Netlify, so that we can use other nightly-only features like doc(cfg)
. We have a special cfg
attribute that we tell docs.rs to pass when building the documentation
Lines 75 to 77 in b358201
[package.metadata.docs.rs] | |
all-features = true | |
rustdoc-args = ["--cfg", "docsrs"] |
and use it to guard nightly-only RustDoc features:
Line 819 in b358201
#![cfg_attr(docsrs, feature(doc_cfg))] |
Therefore, we could add a
#![cfg_attr(docsrs, deny(intra_doc_link_resolution_failure))]
to get nice errors when links are broken, and switch all internal links to use intra-RustDoc links.
Alternatives
Making this change would have one major downside: it would mean that building the docs locally on a stable compiler would result in none of the links working. This is different from the current use of doc(cfg)
attributes: when built on stable, the docs are still basically usable, they're just missing some additional information about feature flags. With links broken, the docs are significantly less usable. Therefore, we might want to leave things the way they are currently.
However, the rendered docs on Netlify (for branches) and on docs.rs (for published releases) would be rendered correctly, and these can be used instead in most cases. For the handful of users who do need to be able to build docs locally (such as when working on tracing
crates offline), we could add a note to the CONTRIBUTING.md documentation on building docs locally, and state that docs should be built using RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc ...
.
It's worth noting that a majority of other major crates, including Tokio have determined that it's acceptable to require nightly for building docs...