Skip to content

Commit f7af780

Browse files
committed
rustdoc: Create anchor pages for primitive types
This commit adds support in rustdoc to recognize the `#[doc(primitive = "foo")]` attribute. This attribute indicates that the current module is the "owner" of the primitive type `foo`. For rustdoc, this means that the doc-comment for the module is the doc-comment for the primitive type, plus a signal to all downstream crates that hyperlinks for primitive types will be directed at the crate containing the `#[doc]` directive. Additionally, rustdoc will favor crates closest to the one being documented which "implements the primitive type". For example, documentation of libcore links to libcore for primitive types, but documentation for libstd and beyond all links to libstd for primitive types. This change involves no compiler modifications, it is purely a rustdoc change. The landing pages for the primitive types primarily serve to show a list of implemented traits for the primitive type itself. The primitive types documented includes both strings and slices in a semi-ad-hoc way, but in a way that should provide at least somewhat meaningful documentation. Closes rust-lang#14474
1 parent 949bfbc commit f7af780

37 files changed

+443
-87
lines changed

src/libcore/bool.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//!
1313
//! A `to_bit` conversion function.
1414
15+
#![doc(primitive = "bool")]
16+
1517
use num::{Int, one, zero};
1618

1719
/////////////////////////////////////////////////////////////////////////////

src/libcore/char.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
//! and, as such, should be performed via the `from_u32` function..
2525
2626
#![allow(non_snake_case_functions)]
27+
#![doc(primitive = "char")]
2728

2829
use mem::transmute;
2930
use option::{None, Option, Some};

src/libcore/num/f32.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Operations and constants for 32-bits floats (`f32` type)
1212
13+
#![doc(primitive = "f32")]
14+
1315
use intrinsics;
1416
use mem;
1517
use num::{FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};

src/libcore/num/f64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Operations and constants for 64-bits floats (`f64` type)
1212
13+
#![doc(primitive = "f64")]
14+
1315
use intrinsics;
1416
use mem;
1517
use num::{FPNormal, FPCategory, FPZero, FPSubnormal, FPInfinite, FPNaN};

src/libcore/num/i16.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for signed 16-bits integers (`i16` type)
1212
13+
#![doc(primitive = "i16")]
14+
1315
int_module!(i16, 16)
1416

src/libcore/num/i32.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for signed 32-bits integers (`i32` type)
1212
13+
#![doc(primitive = "i32")]
14+
1315
int_module!(i32, 32)
1416

src/libcore/num/i64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for signed 64-bits integers (`i64` type)
1212
13+
#![doc(primitive = "i64")]
14+
1315
int_module!(i64, 64)
1416

src/libcore/num/i8.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for signed 8-bits integers (`i8` type)
1212
13+
#![doc(primitive = "i8")]
14+
1315
int_module!(i8, 8)
1416

src/libcore/num/int.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Operations and constants for architecture-sized signed integers (`int` type)
1212
13+
#![doc(primitive = "int")]
14+
1315
#[cfg(target_word_size = "32")] int_module!(int, 32)
1416
#[cfg(target_word_size = "64")] int_module!(int, 64)
1517

src/libcore/num/u16.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@
1010

1111
//! Operations and constants for unsigned 16-bits integers (`u16` type)
1212
13+
#![doc(primitive = "u16")]
14+
1315
uint_module!(u16, i16, 16)

src/libcore/num/u32.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for unsigned 32-bits integers (`u32` type)
1212
13+
#![doc(primitive = "u32")]
14+
1315
uint_module!(u32, i32, 32)
1416

src/libcore/num/u64.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for unsigned 64-bits integer (`u64` type)
1212
13+
#![doc(primitive = "u64")]
14+
1315
uint_module!(u64, i64, 64)
1416

src/libcore/num/u8.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for unsigned 8-bits integers (`u8` type)
1212
13+
#![doc(primitive = "u8")]
14+
1315
uint_module!(u8, i8, 8)
1416

src/libcore/num/uint.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
//! Operations and constants for architecture-sized unsigned integers (`uint` type)
1212
13+
#![doc(primitive = "uint")]
14+
1315
uint_module!(uint, int, ::int::BITS)
1416

src/libcore/slice.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//!
1313
//! For more details `std::slice`.
1414
15+
#![doc(primitive = "slice")]
16+
1517
use mem::transmute;
1618
use clone::Clone;
1719
use container::Container;

src/libcore/str.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//!
1313
//! For more details, see std::str
1414
15+
#![doc(primitive = "str")]
16+
1517
use mem;
1618
use char;
1719
use clone::Clone;

src/libcore/tuple.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
//! assert_eq!(d, (0u32, 0.0f32));
6060
//! ```
6161
62+
#![doc(primitive = "tuple")]
63+
6264
use clone::Clone;
6365
#[cfg(not(test))] use cmp::*;
6466
#[cfg(not(test))] use default::Default;

0 commit comments

Comments
 (0)