Skip to content

Commit 438b013

Browse files
authored
docs: use intra-doc links instead of relative file paths (#2068)
## Motivation #940, I guess. I kept running into the odd broken link in the docs and eventually realized it's because a lot of stuff is reexported in parent modules and so the file path based relative links couldn't possibly work in all contexts. Looks like master already underwent this treatment but I suspect this is easier than backporting. ## Solution Intra-doc links seem pretty good. I started with ``` find -name \*.rs -exec sed -i -e ' s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./\w\+\.\(\w\+\)\.html@\1super::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./\(\w\+\)/\w\+\.\(\w\+\)\.html@\1super::\2::\3@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./\.\./\w\+\.\(\w\+\)\.html@\1super::super::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./\.\./\(\w\+\)/\w\+\.\(\w\+\)\.html@\1super::super::\2::\3@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./\(\w\+\)/index\.html@\1super::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./index\.html@\1super@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\.\./\(\w\+\)/\?$@\1super::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\./\w\+\.\(\w\+\)\.html@\1self::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\./\(\w\+\)/\w\+\.\(\w\+\)\.html@\1self::\2::\3@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\./\(\w\+\)/index\.html@\1self::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\./index\.html@\1self@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\./\(\w\+\)/\?$@\1self::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\w\+\.\(\w\+\)\.html@\1self::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\(\w\+\)/\w\+\.\(\w\+\)\.html@\1self::\2::\3@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\(\w\+\)/index\.html@\1self::\2@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?index\.html@\1self@; s@\(//. \[[^]]*\]:\s\+\)[:"]\?\(\w\+\)/\?$@\1self::\2@; s@\(//. \[[^]]*\]:\s\+[A-Za-z_0-9:]\+\)#method\.\(\w\+\)@\1::\2@; ' {} + ``` and then removed redundant `self::`s when I realized you don't actually need a `::` in the links, and fixed stuff up by hand as I ran into errors from ``` x='--cfg docsrs --cfg tracing_unstable'; RUSTFLAGS=$x RUSTDOCFLAGS=$x cargo doc --all-features ``` I hope that's roughly how the docs are supposed to work. I understand this is a relatively big unsolicited change in that it touches a whole lot of files (definitely went further than I originally intended), I'm happy to revise or split or reduce scope of this PR as desired.
1 parent 9d10e2c commit 438b013

File tree

40 files changed

+386
-390
lines changed

40 files changed

+386
-390
lines changed

tracing-appender/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! *Compiler support: [requires `rustc` 1.53+][msrv]*
1111
//!
1212
//! [msrv]: #supported-rust-versions
13-
//! [file_appender]: ./rolling/struct.RollingFileAppender.html
13+
//! [file_appender]: rolling::RollingFileAppender
1414
//! [tracing]: https://docs.rs/tracing/
1515
//!
1616
//! # Usage
@@ -88,12 +88,12 @@
8888
//!
8989
//! The [`non_blocking` module][non_blocking]'s documentation provides more detail on how to use `non_blocking`.
9090
//!
91-
//! [non_blocking]: ./non_blocking/index.html
91+
//! [non_blocking]: mod@non_blocking
9292
//! [write]: https://doc.rust-lang.org/std/io/trait.Write.html
93-
//! [guard]: ./non_blocking/struct.WorkerGuard.html
94-
//! [rolling]: ./rolling/index.html
93+
//! [guard]: non_blocking::WorkerGuard
94+
//! [rolling]: rolling
9595
//! [make_writer]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/trait.MakeWriter.html
96-
//! [rolling_struct]: ./rolling/struct.RollingFileAppender.html
96+
//! [rolling_struct]: rolling::RollingFileAppender
9797
//! [fmt_subscriber]: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/fmt/struct.Subscriber.html
9898
//!
9999
//! ## Non-Blocking Rolling File Appender
@@ -166,7 +166,7 @@ pub(crate) mod sync;
166166
///
167167
/// See the [`non_blocking` module's docs][non_blocking]'s for more details.
168168
///
169-
/// [non_blocking]: ./non_blocking/index.html
169+
/// [non_blocking]: mod@non_blocking
170170
///
171171
/// # Examples
172172
///

tracing-appender/src/non_blocking.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! tracing_appender::non_blocking(std::io::stdout())
2020
//! # }
2121
//! ```
22-
//! [builder]: ./struct.NonBlockingBuilder.html#method.default
22+
//! [builder]: NonBlockingBuilder::default
2323
//!
2424
//! <br/> This function returns a tuple of `NonBlocking` and `WorkerGuard`.
2525
//! `NonBlocking` implements [`MakeWriter`] which integrates with `tracing_subscriber`.
@@ -33,7 +33,7 @@
3333
//!
3434
//! See [`WorkerGuard`][worker_guard] for examples of using the guard.
3535
//!
36-
//! [worker_guard]: ./struct.WorkerGuard.html
36+
//! [worker_guard]: WorkerGuard
3737
//!
3838
//! # Examples
3939
//!
@@ -65,7 +65,7 @@ use tracing_subscriber::fmt::MakeWriter;
6565
/// backpressure will be exerted on senders, causing them to block their
6666
/// respective threads until there is available capacity.
6767
///
68-
/// [non-blocking]: ./struct.NonBlocking.html
68+
/// [non-blocking]: NonBlocking
6969
/// Recommended to be a power of 2.
7070
pub const DEFAULT_BUFFERED_LINES_LIMIT: usize = 128_000;
7171

@@ -78,7 +78,7 @@ pub const DEFAULT_BUFFERED_LINES_LIMIT: usize = 128_000;
7878
/// terminates abruptly (such as through an uncaught `panic` or a `std::process::exit`), some spans
7979
/// or events may not be written.
8080
///
81-
/// [`NonBlocking`]: ./struct.NonBlocking.html
81+
/// [`NonBlocking`]: NonBlocking
8282
/// Since spans/events and events recorded near a crash are often necessary for diagnosing the failure,
8383
/// `WorkerGuard` provides a mechanism to ensure that _all_ buffered logs are flushed to their output.
8484
/// `WorkerGuard` should be assigned in the `main` function or whatever the entrypoint of the program is.
@@ -145,8 +145,8 @@ impl NonBlocking {
145145
/// The returned `NonBlocking` writer will have the [default configuration][default] values.
146146
/// Other configurations can be specified using the [builder] interface.
147147
///
148-
/// [default]: ./struct.NonBlockingBuilder.html#method.default
149-
/// [builder]: ./struct.NonBlockingBuilder.html
148+
/// [default]: NonBlockingBuilder::default
149+
/// [builder]: NonBlockingBuilder
150150
pub fn new<T: Write + Send + Sync + 'static>(writer: T) -> (NonBlocking, WorkerGuard) {
151151
NonBlockingBuilder::default().finish(writer)
152152
}
@@ -183,7 +183,7 @@ impl NonBlocking {
183183

184184
/// A builder for [`NonBlocking`][non-blocking].
185185
///
186-
/// [non-blocking]: ./struct.NonBlocking.html
186+
/// [non-blocking]: NonBlocking
187187
#[derive(Debug)]
188188
pub struct NonBlockingBuilder {
189189
buffered_lines_limit: usize,

tracing-appender/src/rolling.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A rolling file appender.
22
//!
3-
//! Creates a new log file at a fixed frequency as defined by [`Rotation`](struct.Rotation.html).
3+
//! Creates a new log file at a fixed frequency as defined by [`Rotation`][self::Rotation].
44
//! Logs will be written to this file for the duration of the period and will automatically roll over
55
//! to the newly created log file once the time period has elapsed.
66
//!
@@ -17,10 +17,10 @@
1717
//! will be created daily
1818
//! - [`Rotation::never()`][never()]: This will result in log file located at `some_directory/log_file_name`
1919
//!
20-
//! [minutely]: fn.minutely.html
21-
//! [hourly]: fn.hourly.html
22-
//! [daily]: fn.daily.html
23-
//! [never]: fn.never.html
20+
//! [minutely]: minutely
21+
//! [hourly]: hourly
22+
//! [daily]: daily
23+
//! [never]: never
2424
//!
2525
//! # Examples
2626
//!
@@ -114,7 +114,7 @@ impl RollingFileAppender {
114114
/// Creates a new `RollingFileAppender`.
115115
///
116116
/// A `RollingFileAppender` will have a fixed rotation whose frequency is
117-
/// defined by [`Rotation`](struct.Rotation.html). The `directory` and
117+
/// defined by [`Rotation`][self::Rotation]. The `directory` and
118118
/// `file_name_prefix` arguments determine the location and file name's _prefix_
119119
/// of the log file. `RollingFileAppender` will automatically append the current date
120120
/// and hour (UTC format) to the file name.
@@ -126,10 +126,10 @@ impl RollingFileAppender {
126126
/// - [`Rotation::daily()`][daily],
127127
/// - [`Rotation::never()`][never()]
128128
///
129-
/// [minutely]: fn.minutely.html
130-
/// [hourly]: fn.hourly.html
131-
/// [daily]: fn.daily.html
132-
/// [never]: fn.never.html
129+
/// [minutely]: minutely
130+
/// [hourly]: hourly
131+
/// [daily]: daily
132+
/// [never]: never
133133
///
134134
/// # Examples
135135
/// ```rust
@@ -284,7 +284,7 @@ pub fn hourly(
284284
/// a non-blocking, daily file appender.
285285
///
286286
/// A `RollingFileAppender` has a fixed rotation whose frequency is
287-
/// defined by [`Rotation`](struct.Rotation.html). The `directory` and
287+
/// defined by [`Rotation`][self::Rotation]. The `directory` and
288288
/// `file_name_prefix` arguments determine the location and file name's _prefix_
289289
/// of the log file. `RollingFileAppender` automatically appends the current date in UTC.
290290
///

tracing-attributes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
//!
3737
//! [`tracing`]: https://crates.io/crates/tracing
3838
//! [span]: https://docs.rs/tracing/latest/tracing/span/index.html
39-
//! [instrument]: attr.instrument.html
39+
//! [instrument]: macro@self::instrument
4040
//!
4141
//! ## Supported Rust Versions
4242
//!

tracing-core/src/callsite.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,30 +77,29 @@ impl Registry {
7777
pub trait Callsite: Sync {
7878
/// Sets the [`Interest`] for this callsite.
7979
///
80-
/// [`Interest`]: ../subscriber/struct.Interest.html
80+
/// [`Interest`]: super::subscriber::Interest
8181
fn set_interest(&self, interest: Interest);
8282

8383
/// Returns the [metadata] associated with the callsite.
8484
///
85-
/// [metadata]: ../metadata/struct.Metadata.html
85+
/// [metadata]: super::metadata::Metadata
8686
fn metadata(&self) -> &Metadata<'_>;
8787
}
8888

8989
/// Uniquely identifies a [`Callsite`]
9090
///
9191
/// Two `Identifier`s are equal if they both refer to the same callsite.
9292
///
93-
/// [`Callsite`]: ../callsite/trait.Callsite.html
93+
/// [`Callsite`]: super::callsite::Callsite
9494
#[derive(Clone)]
9595
pub struct Identifier(
9696
/// **Warning**: The fields on this type are currently `pub` because it must
9797
/// be able to be constructed statically by macros. However, when `const
9898
/// fn`s are available on stable Rust, this will no longer be necessary.
9999
/// Thus, these fields are *not* considered stable public API, and they may
100100
/// change warning. Do not rely on any fields on `Identifier`. When
101-
/// constructing new `Identifier`s, use the `identify_callsite!` macro or
102-
/// the `Callsite::id` function instead.
103-
// TODO: When `Callsite::id` is a const fn, this need no longer be `pub`.
101+
/// constructing new `Identifier`s, use the `identify_callsite!` macro
102+
/// instead.
104103
#[doc(hidden)]
105104
pub &'static dyn Callsite,
106105
);
@@ -119,11 +118,11 @@ pub struct Identifier(
119118
/// implementation at runtime, then it **must** call this function after that
120119
/// value changes, in order for the change to be reflected.
121120
///
122-
/// [`max_level_hint`]: ../subscriber/trait.Subscriber.html#method.max_level_hint
123-
/// [`Callsite`]: ../callsite/trait.Callsite.html
124-
/// [`enabled`]: ../subscriber/trait.Subscriber.html#tymethod.enabled
125-
/// [`Interest::sometimes()`]: ../subscriber/struct.Interest.html#method.sometimes
126-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
121+
/// [`max_level_hint`]: super::subscriber::Subscriber::max_level_hint
122+
/// [`Callsite`]: super::callsite::Callsite
123+
/// [`enabled`]: super::subscriber::Subscriber#tymethod.enabled
124+
/// [`Interest::sometimes()`]: super::subscriber::Interest::sometimes
125+
/// [`Subscriber`]: super::subscriber::Subscriber
127126
pub fn rebuild_interest_cache() {
128127
let mut registry = REGISTRY.lock().unwrap();
129128
registry.rebuild_interest();

0 commit comments

Comments
 (0)