Skip to content

Commit e8d2567

Browse files
authored
docs: switch to intra-doc links in tracing-core (#1010)
## Motivation This caught multiple broken links in the documentation. Partially addresses #940. ## Solution Use intra-doc links so rustdoc will give a loud warning if the documentation has errors. Most of these were auto-converted with ``` rg -l '\[.*\]: .*(trait|struct|enum|fn)\..*\.html*' | grep '\.rs$' | xargs sed -i 's#\.\./\(.*\.html\)#super::\1#g; s#\([a-z]\)/\([a-z]\)#\1::\2#g; s#[a-z]\+\.\([a-zA-Z]\+\)\.html#\1#; s/\([a-z]\)#\(ty\)\?method./\1::/; s/#\(ty\)\?method./Self::/' ``` The rest were massaged by hand. In particular `<dyn Subscriber>::downcast_ref` isn't yet supported by rustdoc and can't be converted.
1 parent 04bbb15 commit e8d2567

File tree

8 files changed

+185
-198
lines changed

8 files changed

+185
-198
lines changed

tracing-core/src/callsite.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,20 @@ struct Registry {
3838
pub trait Callsite: Sync {
3939
/// Sets the [`Interest`] for this callsite.
4040
///
41-
/// [`Interest`]: ../subscriber/struct.Interest.html
41+
/// [`Interest`]: super::subscriber::Interest
4242
fn set_interest(&self, interest: Interest);
4343

4444
/// Returns the [metadata] associated with the callsite.
4545
///
46-
/// [metadata]: ../metadata/struct.Metadata.html
46+
/// [metadata]: super::metadata::Metadata
4747
fn metadata(&self) -> &Metadata<'_>;
4848
}
4949

5050
/// Uniquely identifies a [`Callsite`]
5151
///
5252
/// Two `Identifier`s are equal if they both refer to the same callsite.
5353
///
54-
/// [`Callsite`]: ../callsite/trait.Callsite.html
54+
/// [`Callsite`]: super::callsite::Callsite
5555
#[derive(Clone)]
5656
pub struct Identifier(
5757
/// **Warning**: The fields on this type are currently `pub` because it must
@@ -92,11 +92,11 @@ pub struct Registration<T = &'static dyn Callsite> {
9292
/// implementation at runtime, then it **must** call this function after that
9393
/// value changes, in order for the change to be reflected.
9494
///
95-
/// [`max_level_hint`]: ../subscriber/trait.Subscriber.html#method.max_level_hint
96-
/// [`Callsite`]: ../callsite/trait.Callsite.html
97-
/// [`enabled`]: ../subscriber/trait.Subscriber.html#tymethod.enabled
98-
/// [`Interest::sometimes()`]: ../subscriber/struct.Interest.html#method.sometimes
99-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
95+
/// [`max_level_hint`]: super::subscriber::Subscriber::max_level_hint
96+
/// [`Callsite`]: super::callsite::Callsite
97+
/// [`enabled`]: super::subscriber::Subscriber::enabled
98+
/// [`Interest::sometimes()`]: super::subscriber::Interest::sometimes
99+
/// [`Subscriber`]: super::subscriber::Subscriber
100100
pub fn rebuild_interest_cache() {
101101
let mut dispatchers = REGISTRY.dispatchers.lock().unwrap();
102102
let callsites = &REGISTRY.callsites;

tracing-core/src/dispatcher.rs

+62-70
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,10 @@
113113
//! </div>
114114
//! <div class="example-wrap" style="display:inline-block">
115115
//! <pre class="ignore" style="white-space:normal;font:inherit;">
116-
//! <strong>Note</strong>:the thread-local scoped dispatcher
117-
//! (<a href="#fn.with_default"><code>with_default</code></a>) requires the
118-
//! Rust standard library. <code>no_std</code> users should use
119-
//! <a href="#fn.set_global_default"><code>set_global_default</code></a>
120-
//! instead.
116+
//!
117+
//! **Note**: the thread-local scoped dispatcher ([`with_default`]) requires the
118+
//! Rust standard library. `no_std` users should use [`set_global_default`] instead.
119+
//!
121120
//! </pre></div>
122121
//!
123122
//! ## Accessing the Default Subscriber
@@ -126,12 +125,6 @@
126125
//! [`get_default`] function, which executes a closure with a reference to the
127126
//! currently default `Dispatch`. This is used primarily by `tracing`
128127
//! instrumentation.
129-
//!
130-
//! [`Subscriber`]: struct.Subscriber.html
131-
//! [`with_default`]: fn.with_default.html
132-
//! [`set_global_default`]: fn.set_global_default.html
133-
//! [`get_default`]: fn.get_default.html
134-
//! [`Dispatch`]: struct.Dispatch.html
135128
use crate::{
136129
callsite, span,
137130
subscriber::{self, Subscriber},
@@ -154,8 +147,6 @@ use crate::stdlib::{
154147
};
155148

156149
/// `Dispatch` trace data to a [`Subscriber`].
157-
///
158-
/// [`Subscriber`]: trait.Subscriber.html
159150
#[derive(Clone)]
160151
pub struct Dispatch {
161152
subscriber: Arc<dyn Subscriber + Send + Sync>,
@@ -217,14 +208,15 @@ pub struct DefaultGuard(Option<Dispatch>);
217208
/// <div class="example-wrap" style="display:inline-block">
218209
/// <pre class="ignore" style="white-space:normal;font:inherit;">
219210
/// <strong>Note</strong>: This function required the Rust standard library.
220-
/// <code>no_std</code> users should use <a href="../fn.set_global_default.html">
221-
/// <code>set_global_default</code></a> instead.
211+
/// <!-- hack: this whitespace makes rustdoc interpret the next line as markdown again -->
212+
///
213+
/// `no_std` users should use [`set_global_default`] instead.
214+
///
222215
/// </pre></div>
223216
///
224-
/// [span]: ../span/index.html
225-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
226-
/// [`Event`]: ../event/struct.Event.html
227-
/// [`set_global_default`]: ../fn.set_global_default.html
217+
/// [span]: super::span
218+
/// [`Subscriber`]: super::subscriber::Subscriber
219+
/// [`Event`]: super::event::Event
228220
#[cfg(feature = "std")]
229221
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
230222
pub fn with_default<T>(dispatcher: &Dispatch, f: impl FnOnce() -> T) -> T {
@@ -244,12 +236,11 @@ pub fn with_default<T>(dispatcher: &Dispatch, f: impl FnOnce() -> T) -> T {
244236
/// </div>
245237
/// <div class="example-wrap" style="display:inline-block">
246238
/// <pre class="ignore" style="white-space:normal;font:inherit;">
247-
/// <strong>Note</strong>: This function required the Rust standard library.
248-
/// <code>no_std</code> users should use <a href="../fn.set_global_default.html">
249-
/// <code>set_global_default</code></a> instead.
250-
/// </pre></div>
251239
///
252-
/// [`set_global_default`]: ../fn.set_global_default.html
240+
/// **Note**: This function required the Rust standard library.
241+
/// `no_std` users should use [`set_global_default`] instead.
242+
///
243+
/// </pre></div>
253244
#[cfg(feature = "std")]
254245
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
255246
#[must_use = "Dropping the guard unregisters the dispatcher."]
@@ -276,9 +267,9 @@ pub fn set_default(dispatcher: &Dispatch) -> DefaultGuard {
276267
/// executables that depend on the library try to set the default later.
277268
/// </pre></div>
278269
///
279-
/// [span]: ../span/index.html
280-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
281-
/// [`Event`]: ../event/struct.Event.html
270+
/// [span]: super::span
271+
/// [`Subscriber`]: super::subscriber::Subscriber
272+
/// [`Event`]: super::event::Event
282273
pub fn set_global_default(dispatcher: Dispatch) -> Result<(), SetGlobalDefaultError> {
283274
if GLOBAL_INIT.compare_and_swap(UNINITIALIZED, INITIALIZING, Ordering::SeqCst) == UNINITIALIZED
284275
{
@@ -325,7 +316,7 @@ impl error::Error for SetGlobalDefaultError {}
325316
/// called while inside of another `get_default`, that closure will be provided
326317
/// with `Dispatch::none` rather than the previously set dispatcher.
327318
///
328-
/// [dispatcher]: ../dispatcher/struct.Dispatch.html
319+
/// [dispatcher]: super::dispatcher::Dispatch
329320
#[cfg(feature = "std")]
330321
pub fn get_default<T, F>(mut f: F) -> T
331322
where
@@ -348,7 +339,7 @@ where
348339
/// called while inside of another `get_default`, that closure will be provided
349340
/// with `Dispatch::none` rather than the previously set dispatcher.
350341
///
351-
/// [dispatcher]: ../dispatcher/struct.Dispatch.html
342+
/// [dispatcher]: super::dispatcher::Dispatch
352343
#[cfg(feature = "std")]
353344
#[doc(hidden)]
354345
#[inline(never)]
@@ -363,7 +354,7 @@ pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
363354

364355
/// Executes a closure with a reference to the current [dispatcher].
365356
///
366-
/// [dispatcher]: ../dispatcher/struct.Dispatch.html
357+
/// [dispatcher]: super::dispatcher::Dispatch
367358
#[cfg(not(feature = "std"))]
368359
#[doc(hidden)]
369360
pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
@@ -373,7 +364,7 @@ pub fn get_current<T>(f: impl FnOnce(&Dispatch) -> T) -> Option<T> {
373364

374365
/// Executes a closure with a reference to the current [dispatcher].
375366
///
376-
/// [dispatcher]: ../dispatcher/struct.Dispatch.html
367+
/// [dispatcher]: super::dispatcher::Dispatch
377368
#[cfg(not(feature = "std"))]
378369
pub fn get_default<T, F>(mut f: F) -> T
379370
where
@@ -412,7 +403,7 @@ impl Dispatch {
412403

413404
/// Returns a `Dispatch` that forwards to the given [`Subscriber`].
414405
///
415-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
406+
/// [`Subscriber`]: super::subscriber::Subscriber
416407
pub fn new<S>(subscriber: S) -> Self
417408
where
418409
S: Subscriber + Send + Sync + 'static,
@@ -434,8 +425,8 @@ impl Dispatch {
434425
/// This calls the [`register_callsite`] function on the [`Subscriber`]
435426
/// that this `Dispatch` forwards to.
436427
///
437-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
438-
/// [`register_callsite`]: ../subscriber/trait.Subscriber.html#method.register_callsite
428+
/// [`Subscriber`]: super::subscriber::Subscriber
429+
/// [`register_callsite`]: super::subscriber::Subscriber::register_callsite
439430
#[inline]
440431
pub fn register_callsite(&self, metadata: &'static Metadata<'static>) -> subscriber::Interest {
441432
self.subscriber.register_callsite(metadata)
@@ -448,9 +439,9 @@ impl Dispatch {
448439
/// This calls the [`max_level_hint`] function on the [`Subscriber`]
449440
/// that this `Dispatch` forwards to.
450441
///
451-
/// [level]: ../struct.Level.html
452-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
453-
/// [`register_callsite`]: ../subscriber/trait.Subscriber.html#method.max_level_hint
442+
/// [level]: super::Level
443+
/// [`Subscriber`]: super::subscriber::Subscriber
444+
/// [`register_callsite`]: super::subscriber::Subscriber::max_level_hint
454445
// TODO(eliza): consider making this a public API?
455446
#[inline]
456447
pub(crate) fn max_level_hint(&self) -> Option<LevelFilter> {
@@ -463,9 +454,9 @@ impl Dispatch {
463454
/// This calls the [`new_span`] function on the [`Subscriber`] that this
464455
/// `Dispatch` forwards to.
465456
///
466-
/// [ID]: ../span/struct.Id.html
467-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
468-
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
457+
/// [ID]: super::span::Id
458+
/// [`Subscriber`]: super::subscriber::Subscriber
459+
/// [`new_span`]: super::subscriber::Subscriber::new_span
469460
#[inline]
470461
pub fn new_span(&self, span: &span::Attributes<'_>) -> span::Id {
471462
self.subscriber.new_span(span)
@@ -476,8 +467,8 @@ impl Dispatch {
476467
/// This calls the [`record`] function on the [`Subscriber`] that this
477468
/// `Dispatch` forwards to.
478469
///
479-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
480-
/// [`record`]: ../subscriber/trait.Subscriber.html#method.record
470+
/// [`Subscriber`]: super::subscriber::Subscriber
471+
/// [`record`]: super::subscriber::Subscriber::record
481472
#[inline]
482473
pub fn record(&self, span: &span::Id, values: &span::Record<'_>) {
483474
self.subscriber.record(span, values)
@@ -489,8 +480,8 @@ impl Dispatch {
489480
/// This calls the [`record_follows_from`] function on the [`Subscriber`]
490481
/// that this `Dispatch` forwards to.
491482
///
492-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
493-
/// [`record_follows_from`]: ../subscriber/trait.Subscriber.html#method.record_follows_from
483+
/// [`Subscriber`]: super::subscriber::Subscriber
484+
/// [`record_follows_from`]: super::subscriber::Subscriber::record_follows_from
494485
#[inline]
495486
pub fn record_follows_from(&self, span: &span::Id, follows: &span::Id) {
496487
self.subscriber.record_follows_from(span, follows)
@@ -502,9 +493,9 @@ impl Dispatch {
502493
/// This calls the [`enabled`] function on the [`Subscriber`] that this
503494
/// `Dispatch` forwards to.
504495
///
505-
/// [metadata]: ../metadata/struct.Metadata.html
506-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
507-
/// [`enabled`]: ../subscriber/trait.Subscriber.html#method.enabled
496+
/// [metadata]: super::metadata::Metadata
497+
/// [`Subscriber`]: super::subscriber::Subscriber
498+
/// [`enabled`]: super::subscriber::Subscriber::enabled
508499
#[inline]
509500
pub fn enabled(&self, metadata: &Metadata<'_>) -> bool {
510501
self.subscriber.enabled(metadata)
@@ -515,9 +506,9 @@ impl Dispatch {
515506
/// This calls the [`event`] function on the [`Subscriber`] that this
516507
/// `Dispatch` forwards to.
517508
///
518-
/// [`Event`]: ../event/struct.Event.html
519-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
520-
/// [`event`]: ../subscriber/trait.Subscriber.html#method.event
509+
/// [`Event`]: super::event::Event
510+
/// [`Subscriber`]: super::subscriber::Subscriber
511+
/// [`event`]: super::subscriber::Subscriber::event
521512
#[inline]
522513
pub fn event(&self, event: &Event<'_>) {
523514
self.subscriber.event(event)
@@ -528,8 +519,8 @@ impl Dispatch {
528519
/// This calls the [`enter`] function on the [`Subscriber`] that this
529520
/// `Dispatch` forwards to.
530521
///
531-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
532-
/// [`enter`]: ../subscriber/trait.Subscriber.html#method.enter
522+
/// [`Subscriber`]: super::subscriber::Subscriber
523+
/// [`enter`]: super::subscriber::Subscriber::enter
533524
#[inline]
534525
pub fn enter(&self, span: &span::Id) {
535526
self.subscriber.enter(span);
@@ -540,8 +531,8 @@ impl Dispatch {
540531
/// This calls the [`exit`] function on the [`Subscriber`] that this
541532
/// `Dispatch` forwards to.
542533
///
543-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
544-
/// [`exit`]: ../subscriber/trait.Subscriber.html#method.exit
534+
/// [`Subscriber`]: super::subscriber::Subscriber
535+
/// [`exit`]: super::subscriber::Subscriber::exit
545536
#[inline]
546537
pub fn exit(&self, span: &span::Id) {
547538
self.subscriber.exit(span);
@@ -557,10 +548,10 @@ impl Dispatch {
557548
/// This calls the [`clone_span`] function on the `Subscriber` that this
558549
/// `Dispatch` forwards to.
559550
///
560-
/// [span ID]: ../span/struct.Id.html
561-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
562-
/// [`clone_span`]: ../subscriber/trait.Subscriber.html#method.clone_span
563-
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
551+
/// [span ID]: super::span::Id
552+
/// [`Subscriber`]: super::subscriber::Subscriber
553+
/// [`clone_span`]: super::subscriber::Subscriber::clone_span
554+
/// [`new_span`]: super::subscriber::Subscriber::new_span
564555
#[inline]
565556
pub fn clone_span(&self, id: &span::Id) -> span::Id {
566557
self.subscriber.clone_span(&id)
@@ -580,16 +571,17 @@ impl Dispatch {
580571
/// <div class="tooltip compile_fail" style="">&#x26a0; &#xfe0f;<span class="tooltiptext">Warning</span></div>
581572
/// </div>
582573
/// <div class="example-wrap" style="display:inline-block"><pre class="compile_fail" style="white-space:normal;font:inherit;">
583-
/// <strong>Deprecated</strong>: The <a href="#method.try_close"><code>try_close</code></a>
584-
/// method is functionally identical, but returns <code>true</code> if the span is now closed.
574+
///
575+
/// **Deprecated**: The [`try_close`] method is functionally identical, but returns `true` if the span is now closed.
585576
/// It should be used instead of this method.
577+
///
586578
/// </pre></div>
587579
///
588-
/// [span ID]: ../span/struct.Id.html
589-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
590-
/// [`drop_span`]: ../subscriber/trait.Subscriber.html#method.drop_span
591-
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
592-
/// [`try_close`]: #method.try_close
580+
/// [span ID]: super::span::Id
581+
/// [`Subscriber`]: super::subscriber::Subscriber
582+
/// [`drop_span`]: super::subscriber::Subscriber::drop_span
583+
/// [`new_span`]: super::subscriber::Subscriber::new_span
584+
/// [`try_close`]: Self::try_close
593585
#[inline]
594586
#[deprecated(since = "0.1.2", note = "use `Dispatch::try_close` instead")]
595587
pub fn drop_span(&self, id: span::Id) {
@@ -608,10 +600,10 @@ impl Dispatch {
608600
/// This calls the [`try_close`] function on the [`Subscriber`] that this
609601
/// `Dispatch` forwards to.
610602
///
611-
/// [span ID]: ../span/struct.Id.html
612-
/// [`Subscriber`]: ../subscriber/trait.Subscriber.html
613-
/// [`try_close`]: ../subscriber/trait.Subscriber.html#method.try_close
614-
/// [`new_span`]: ../subscriber/trait.Subscriber.html#method.new_span
603+
/// [span ID]: super::span::Id
604+
/// [`Subscriber`]: super::subscriber::Subscriber
605+
/// [`try_close`]: super::subscriber::Subscriber::try_close
606+
/// [`new_span`]: super::subscriber::Subscriber::new_span
615607
#[inline]
616608
pub fn try_close(&self, id: span::Id) -> bool {
617609
self.subscriber.try_close(id)
@@ -622,7 +614,7 @@ impl Dispatch {
622614
/// This calls the [`current`] function on the `Subscriber` that this
623615
/// `Dispatch` forwards to.
624616
///
625-
/// [`current`]: ../subscriber/trait.Subscriber.html#method.current
617+
/// [`current`]: super::subscriber::Subscriber::current_span
626618
#[inline]
627619
pub fn current_span(&self) -> span::Current {
628620
self.subscriber.current_span()

tracing-core/src/event.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'a> Event<'a> {
8181

8282
/// Visits all the fields on this `Event` with the specified [visitor].
8383
///
84-
/// [visitor]: ../field/trait.Visit.html
84+
/// [visitor]: super::field::Visit
8585
#[inline]
8686
pub fn record(&self, visitor: &mut dyn field::Visit) {
8787
self.fields.record(visitor);
@@ -94,7 +94,7 @@ impl<'a> Event<'a> {
9494

9595
/// Returns [metadata] describing this `Event`.
9696
///
97-
/// [metadata]: ../struct.Metadata.html
97+
/// [metadata]: super::Metadata
9898
pub fn metadata(&self) -> &'static Metadata<'static> {
9999
self.metadata
100100
}

0 commit comments

Comments
 (0)