Skip to content

Automatic Item linkification part 0 #34474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ use self::Entry::*;
/// however, performance is excellent.
///
/// It is a logic error for a key to be modified in such a way that the key's ordering relative to
/// any other key, as determined by the `Ord` trait, changes while it is in the map. This is
/// normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe code.
/// any other key, as determined by the [`Ord`] trait, changes while it is in the map. This is
/// normally only possible through [`Cell`], [`RefCell`], global state, I/O, or unsafe code.
///
/// # Examples
///
Expand Down Expand Up @@ -126,6 +126,10 @@ use self::Entry::*;
/// let stat = player_stats.entry("attack").or_insert(100);
/// *stat += random_stat_buff();
/// ```
///
/// [`Cell`]: /std/cell/struct.Cell.html
/// [`Ord`]: /std/cmp/trait.Ord.html
/// [`RefCell`]: /std/cell/struct.RefCell.html
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BTreeMap<K, V> {
root: node::Root<K, V>,
Expand Down
41 changes: 30 additions & 11 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// The entry point for panic of Rust threads.
///
/// This macro is used to inject panic into a Rust thread, causing the thread to
/// panic entirely. Each thread's panic can be reaped as the `Box<Any>` type,
/// panic entirely. Each thread's panic can be reaped as the [`Box<Any>`] type,
/// and the single-argument form of the `panic!` macro will be the value which
/// is transmitted.
///
Expand All @@ -33,6 +33,8 @@
/// panic!(4); // panic with the value of 4 to be collected elsewhere
/// panic!("this is a {} {message}", "fancy", message = "message");
/// ```
///
/// [`Box<Any>`]: ../../collections/boxed/struct.Box.html
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one too many ../s for the links you've added in this file. The macros are documented at the crate root so you only need to go up once.

Also this one should really be linking to std::boxed::Box and not collections::boxed::Box.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catches, thanks. My web server was eating the extra '../' so my dead link checker didn't catch that.

Is there any situation where a type is mirrored into std that I shouldn't treat the std version as canonical? e.g. if something in collections mentions Box is it ok for that link to be to std, or will I need custom resolution per lib?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you look into linkchecker.

In my opinion the std docs are most important so as long as the links in that stay within std it shouldn't matter too much about the other crates.

#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable]
Expand Down Expand Up @@ -61,7 +63,7 @@ macro_rules! panic {

/// Macro for printing to the standard output.
///
/// Equivalent to the `println!` macro except that a newline is not printed at
/// Equivalent to the [`println!`] macro except that a newline is not printed at
/// the end of the message.
///
/// Note that stdout is frequently line-buffered by default so it may be
Expand Down Expand Up @@ -91,6 +93,8 @@ macro_rules! panic {
///
/// io::stdout().flush().unwrap();
/// ```
///
/// [`println!`]: ../../std/macro.println!.html
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow_internal_unstable]
Expand All @@ -101,7 +105,7 @@ macro_rules! print {
/// Macro for printing to the standard output, with a newline.
///
/// Use the `format!` syntax to write data to the standard output.
/// See `std::fmt` for more information.
/// See [`std::fmt`] for more information.
///
/// # Panics
///
Expand All @@ -113,6 +117,8 @@ macro_rules! print {
/// println!("hello there!");
/// println!("format {} arguments", "some");
/// ```
///
/// [`std::fmt`]: ../../std/fmt/index.html
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! println {
Expand Down Expand Up @@ -154,7 +160,9 @@ macro_rules! println {
/// # drop(rx2.recv());
/// ```
///
/// For more information about select, see the `std::sync::mpsc::Select` structure.
/// For more information about select, see the [`std::sync::mpsc::Select`] structure.
///
/// [`std::sync::mpsc::Select`]: ../../std/sync/mpsc/struct.Select.html
#[macro_export]
#[unstable(feature = "mpsc_select", issue = "27800")]
macro_rules! select {
Expand Down Expand Up @@ -192,11 +200,11 @@ pub mod builtin {
/// The core macro for formatted string creation & output.
///
/// This macro produces a value of type `fmt::Arguments`. This value can be
/// passed to the functions in `std::fmt` for performing useful functions.
/// All other formatting macros (`format!`, `write!`, `println!`, etc) are
/// passed to the functions in [`std::fmt`] for performing useful functions.
/// All other formatting macros (`format!`, `write!`, [`println!`], etc) are
/// proxied through this one.
///
/// For more information, see the documentation in `std::fmt`.
/// For more information, see the documentation in [`std::fmt`].
///
/// # Examples
///
Expand All @@ -207,6 +215,9 @@ pub mod builtin {
/// assert_eq!(s, format!("hello {}", "world"));
///
/// ```
///
/// [`println!`]: ../../std/macro.println!.html
/// [`std::fmt`]: ../../std/fmt/index.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
Expand All @@ -219,7 +230,7 @@ pub mod builtin {
/// compile time, yielding an expression of type `&'static str`.
///
/// If the environment variable is not defined, then a compilation error
/// will be emitted. To not emit a compile error, use the `option_env!`
/// will be emitted. To not emit a compile error, use the [`option_env!`]
/// macro instead.
///
/// # Examples
Expand All @@ -228,14 +239,16 @@ pub mod builtin {
/// let path: &'static str = env!("PATH");
/// println!("the $PATH variable at the time of compiling was: {}", path);
/// ```
///
/// [`option_env!`]: ../../std/macro.option_env!.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }

/// Optionally inspect an environment variable at compile time.
///
/// If the named environment variable is present at compile time, this will
/// expand into an expression of type `Option<&'static str>` whose value is
/// expand into an expression of type [`Option<&'static str>`] whose value is
/// `Some` of the value of the environment variable. If the environment
/// variable is not present, then this will expand to `None`.
///
Expand All @@ -248,6 +261,8 @@ pub mod builtin {
/// let key: Option<&'static str> = option_env!("SECRET_KEY");
/// println!("the secret key might be: {:?}", key);
/// ```
///
/// [`Option<&'static str>`]: ../../std/option/enum.Option.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
Expand Down Expand Up @@ -303,7 +318,7 @@ pub mod builtin {

/// A macro which expands to the line number on which it was invoked.
///
/// The expanded expression has type `u32`, and the returned line is not
/// The expanded expression has type [`u32`], and the returned line is not
/// the invocation of the `line!()` macro itself, but rather the first macro
/// invocation leading up to the invocation of the `line!()` macro.
///
Expand All @@ -313,13 +328,15 @@ pub mod builtin {
/// let current_line = line!();
/// println!("defined on line: {}", current_line);
/// ```
///
/// [`u32`]: ../../std/primitive.u32.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! line { () => ({ /* compiler built-in */ }) }

/// A macro which expands to the column number on which it was invoked.
///
/// The expanded expression has type `u32`, and the returned column is not
/// The expanded expression has type [`u32`], and the returned column is not
/// the invocation of the `column!()` macro itself, but rather the first macro
/// invocation leading up to the invocation of the `column!()` macro.
///
Expand All @@ -329,6 +346,8 @@ pub mod builtin {
/// let current_col = column!();
/// println!("defined on column: {}", current_col);
/// ```
///
/// [`u32`]: ../../std/primitive.u32.html
#[stable(feature = "rust1", since = "1.0.0")]
#[macro_export]
macro_rules! column { () => ({ /* compiler built-in */ }) }
Expand Down