Skip to content

Commit 6f01226

Browse files
TaKO8KihawkwJoshua Nelson
authored
docs: add deny(broken_intra_doc_links) (#981)
## Motivation In order to get a compiler warning (or error) when links are broken. Closes #940 ## Solution - [x] add `deny(broken_intra_doc_links)` - [x] add a note to the CONTRIBUTING.md documentation on building docs locally Co-authored-by: Eliza Weisman <[email protected]> Co-authored-by: Joshua Nelson <[email protected]>
1 parent fba2ed2 commit 6f01226

File tree

17 files changed

+50
-28
lines changed

17 files changed

+50
-28
lines changed

CONTRIBUTING.md

+12
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,18 @@ To reduce the effort required to review documentation-related changes,
211211
be viewed by clicking the `details` link on the
212212
`netlify/tracing-rs/deploy-preview check` on all pull requests.
213213

214+
### Building Documentation
215+
216+
Tracing's documentation uses nightly-only RustDoc features and lints, like
217+
`doc(cfg)` and `broken_intra_doc_lints`. These features are enabled by
218+
passing `--cfg docsrs` to RustDoc. Therefore, in order to build Tracing's
219+
documentation the same way it would be built by docs.rs, it's necessary to
220+
use the following command:
221+
222+
```bash
223+
RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --no-deps
224+
```
225+
214226
### Commits
215227

216228
It is a recommended best practice to keep your changes as logically grouped as

tracing-appender/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
//! # }
3535
//! ```
3636
//! This creates an hourly rotating file appender that writes to `/some/directory/prefix.log.YYYY-MM-DD-HH`.
37-
//! [`Rotation::DAILY`] and [`Rotation::NEVER`] are the other available options.
37+
//! [`Rotation::DAILY`](rolling::Rotation::DAILY) and [`Rotation::NEVER`](rolling::Rotation::NEVER) are the other available options.
3838
//!
3939
//! The file appender implements [`std::io::Write`][write]. To be used with [`tracing_subscriber::FmtSubscriber`][fmt_subscriber],
4040
//! it must be combined with a [`MakeWriter`][make_writer] implementation to be able to record tracing spans/event.
@@ -127,6 +127,7 @@
127127
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
128128
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
129129
)]
130+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
130131
#![warn(
131132
missing_debug_implementations,
132133
missing_docs,

tracing-attributes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
5858
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
5959
)]
60+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
6061
#![warn(
6162
missing_debug_implementations,
6263
missing_docs,

tracing-core/src/callsite.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Registry {
7272

7373
/// Trait implemented by callsites.
7474
///
75-
/// These functions are only intended to be called by the [`Registry`] which
75+
/// These functions are only intended to be called by the callsite registry, which
7676
/// correctly handles determining the common interest between all subscribers.
7777
pub trait Callsite: Sync {
7878
/// Sets the [`Interest`] for this callsite.
@@ -114,11 +114,12 @@ pub struct Identifier(
114114
/// [`enabled`] is evaluated for every event.
115115
///
116116
/// This function will also re-compute the global maximum level as determined by
117-
/// the [`Subscriber::max_level_hint`] method. If a [`Subscriber`]
117+
/// the [`max_level_hint`] method. If a [`Subscriber`]
118118
/// implementation changes the value returned by its `max_level_hint`
119119
/// implementation at runtime, then it **must** call this function after that
120120
/// value changes, in order for the change to be reflected.
121121
///
122+
/// [`max_level_hint`]: ../subscriber/trait.Subscriber.html#method.max_level_hint
122123
/// [`Callsite`]: ../callsite/trait.Callsite.html
123124
/// [`enabled`]: ../subscriber/trait.Subscriber.html#tymethod.enabled
124125
/// [`Interest::sometimes()`]: ../subscriber/struct.Interest.html#method.sometimes

tracing-core/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
9292
)]
9393
#![cfg_attr(not(feature = "std"), no_std)]
94-
#![cfg_attr(docsrs, feature(doc_cfg))]
94+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
9595
#![warn(
9696
missing_debug_implementations,
9797
missing_docs,

tracing-error/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
//! supported compiler version is not considered a semver breaking change as
186186
//! long as doing so complies with this policy.
187187
//!
188-
#![cfg_attr(docsrs, feature(doc_cfg))]
188+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
189189
#![doc(html_root_url = "https://docs.rs/tracing-error/0.1.2")]
190190
#![doc(
191191
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",

tracing-flame/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
114114
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
115115
)]
116+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
116117
#![warn(
117118
missing_debug_implementations,
118119
missing_docs,

tracing-futures/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
while_true
102102
)]
103103
#![cfg_attr(not(feature = "std"), no_std)]
104-
#![cfg_attr(docsrs, feature(doc_cfg))]
104+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
105105
#[cfg(feature = "std-future")]
106106
use pin_project::pin_project;
107107

tracing-journald/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! # tracing-journald
22
//!
3-
//! Support for logging [`tracing`][tracing] events natively to [journald],
3+
//! Support for logging [`tracing`] events natively to [journald],
44
//! preserving structured information.
55
//!
66
//! ## Overview
@@ -36,6 +36,7 @@
3636
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
3737
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
3838
)]
39+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
3940
#[cfg(unix)]
4041
use std::os::unix::net::UnixDatagram;
4142
use std::{fmt, io, io::Write};

tracing-log/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
111111
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
112112
)]
113-
#![cfg_attr(docsrs, feature(doc_cfg))]
113+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
114114
#![warn(
115115
missing_debug_implementations,
116116
missing_docs,

tracing-macros/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
2+
13
/// Alias of `dbg!` for avoiding conflicts with the `std::dbg!` macro.
24
#[macro_export]
35
macro_rules! trace_dbg {

tracing-opentelemetry/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
9696
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
9797
)]
98+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
9899

99100
/// Implementation of the trace::Layer as a source of OpenTelemetry data.
100101
mod layer;

tracing-serde/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
131131
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
132132
)]
133+
#![cfg_attr(docsrs, deny(broken_intra_doc_links))]
133134
#![warn(
134135
missing_debug_implementations,
135136
// missing_docs, // TODO: add documentation

tracing-subscriber/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
7373
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"
7474
)]
75-
#![cfg_attr(docsrs, feature(doc_cfg))]
75+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
7676
#![warn(
7777
missing_debug_implementations,
7878
missing_docs,

tracing-subscriber/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ where
7979

8080
impl<T> SubscriberInitExt for T where T: Into<Dispatch> {}
8181

82-
/// Error returned by [`try_init`] if a global default subscriber could not be initialized.
82+
/// Error returned by [`try_init`](SubscriberInitExt::try_init) if a global default subscriber could not be initialized.
8383
pub struct TryInitError {
8484
inner: Box<dyn Error + Send + Sync + 'static>,
8585
}

tracing-tower/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(docsrs, feature(doc_cfg))]
1+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
22
#![doc(
33
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",
44
issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/"

tracing/src/lib.rs

+18-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//! ## Spans
3131
//!
3232
//! To record the flow of execution through a program, `tracing` introduces the
33-
//! concept of [spans][span]. Unlike a log line that represents a _moment in
33+
//! concept of [spans]. Unlike a log line that represents a _moment in
3434
//! time_, a span represents a _period of time_ with a beginning and an end. When a
3535
//! program begins executing in a context or performing a unit of work, it
3636
//! _enters_ that context's span, and when it stops executing in that context,
@@ -817,21 +817,22 @@
817817
//! long as doing so complies with this policy.
818818
//!
819819
//! [`log`]: https://docs.rs/log/0.4.6/log/
820-
//! [span]: span/index.html
821-
//! [`Span`]: span/struct.Span.html
822-
//! [`in_scope`]: span/struct.Span.html#method.in_scope
823-
//! [`Event`]: struct.Event.html
824-
//! [event]: struct.Event.html
825-
//! [`Subscriber`]: subscriber/trait.Subscriber.html
826-
//! [Subscriber::event]: subscriber/trait.Subscriber.html#tymethod.event
827-
//! [`enter`]: subscriber/trait.Subscriber.html#tymethod.enter
828-
//! [`exit`]: subscriber/trait.Subscriber.html#tymethod.exit
829-
//! [`enabled`]: subscriber/trait.Subscriber.html#tymethod.enabled
830-
//! [metadata]: struct.Metadata.html
831-
//! [`field::display`]: field/fn.display.html
832-
//! [`field::debug`]: field/fn.debug.html
833-
//! [`set_global_default`]: subscriber/fn.set_global_default.html
834-
//! [`with_default`]: subscriber/fn.with_default.html
820+
//! [span]: mod@span
821+
//! [spans]: mod@span
822+
//! [`Span`]: span::Span
823+
//! [`in_scope`]: span::Span::in_scope
824+
//! [event]: Event
825+
//! [events]: Event
826+
//! [`Subscriber`]: subscriber::Subscriber
827+
//! [Subscriber::event]: subscriber::Subscriber::event
828+
//! [`enter`]: subscriber::Subscriber::enter
829+
//! [`exit`]: subscriber::Subscriber::exit
830+
//! [`enabled`]: subscriber::Subscriber::enabled
831+
//! [metadata]: Metadata
832+
//! [`field::display`]: field::display
833+
//! [`field::debug`]: field::debug
834+
//! [`set_global_default`]: subscriber::set_global_default
835+
//! [`with_default`]: subscriber::with_default
835836
//! [`tokio-rs/tracing`]: https://github.com/tokio-rs/tracing
836837
//! [`tracing-futures`]: https://crates.io/crates/tracing-futures
837838
//! [`tracing-subscriber`]: https://crates.io/crates/tracing-subscriber
@@ -844,7 +845,7 @@
844845
//! [instrument]: https://docs.rs/tracing-attributes/latest/tracing_attributes/attr.instrument.html
845846
//! [flags]: #crate-feature-flags
846847
#![cfg_attr(not(feature = "std"), no_std)]
847-
#![cfg_attr(docsrs, feature(doc_cfg))]
848+
#![cfg_attr(docsrs, feature(doc_cfg), deny(broken_intra_doc_links))]
848849
#![doc(html_root_url = "https://docs.rs/tracing/0.1.20")]
849850
#![doc(
850851
html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png",

0 commit comments

Comments
 (0)