Skip to content

Commit

Permalink
Add primitive documentation to libcore
Browse files Browse the repository at this point in the history
This works by doing two things:
- Adding links that are specific to the crate. Since not all primitive
  items are defined in `core` (due to lang_items), these need to use
  relative links and not intra-doc links.
- Duplicating `primitive_docs` in both core and std. This allows not needing CARGO_PKG_NAME to build the standard library. It also adds a tidy check to make sure they stay the same.
  • Loading branch information
jyn514 committed Sep 12, 2021
1 parent 8c2b6ea commit 69fe39e
Show file tree
Hide file tree
Showing 29 changed files with 1,394 additions and 31 deletions.
1 change: 1 addition & 0 deletions library/core/primitive_docs/box_into_raw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/boxed/struct.Box.html#method.into_raw
1 change: 1 addition & 0 deletions library/core/primitive_docs/fs_file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/fs/struct.File.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/io_bufread.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/io/trait.BufRead.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/io_read.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/io/trait.Read.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/io_seek.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/io/trait.Seek.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/io_write.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/io/trait.Write.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/net_tosocketaddrs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/net/trait.ToSocketAddrs.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/process_exit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/process/fn.exit.html
1 change: 1 addition & 0 deletions library/core/primitive_docs/string_string.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../std/string/struct.String.html
6 changes: 4 additions & 2 deletions library/core/src/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#[lang = "bool"]
impl bool {
/// Returns `Some(t)` if the `bool` is [`true`](keyword.true.html), or `None` otherwise.
/// Returns `Some(t)` if the `bool` is [`true`](../std/keyword.true.html),
/// or `None` otherwise.
///
/// # Examples
///
Expand All @@ -18,7 +19,8 @@ impl bool {
if self { Some(t) } else { None }
}

/// Returns `Some(f())` if the `bool` is [`true`](keyword.true.html), or `None` otherwise.
/// Returns `Some(f())` if the `bool` is [`true`](../std/keyword.true.html),
/// or `None` otherwise.
///
/// # Examples
///
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl char {
/// Converts a `u32` to a `char`.
///
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with
/// [`as`](keyword.as.html):
/// [`as`](../std/keyword.as.html):
///
/// ```
/// let c = '💯';
Expand Down Expand Up @@ -372,7 +372,7 @@ impl char {
/// println!("\\u{{2764}}");
/// ```
///
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
Expand Down Expand Up @@ -448,7 +448,7 @@ impl char {
/// println!("\\n");
/// ```
///
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
Expand Down Expand Up @@ -502,7 +502,7 @@ impl char {
/// println!("\\\"");
/// ```
///
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
Expand Down Expand Up @@ -937,7 +937,7 @@ impl char {
/// println!("i\u{307}");
/// ```
///
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('C'.to_lowercase().to_string(), "c");
Expand Down Expand Up @@ -1002,7 +1002,7 @@ impl char {
/// println!("SS");
/// ```
///
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
///
/// ```
/// assert_eq!('c'.to_uppercase().to_string(), "C");
Expand Down
3 changes: 3 additions & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
#![feature(decl_macro)]
#![feature(doc_cfg)]
#![feature(doc_notable_trait)]
#![feature(doc_primitive)]
#![feature(exhaustive_patterns)]
#![feature(extern_types)]
#![feature(fundamental)]
Expand Down Expand Up @@ -355,3 +356,5 @@ pub mod arch {
/* compiler built-in */
}
}

include!("primitive_docs.rs");
Loading

0 comments on commit 69fe39e

Please sign in to comment.