Skip to content

Lots of improvements to rustdoc #9475

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 16 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
2 changes: 1 addition & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ do
isaac linenoise sync test \
arch/i386 arch/x86_64 arch/arm arch/mips \
libuv libuv/src/ares libuv/src/eio libuv/src/ev \
jemalloc
jemalloc sundown/src sundown/html
do
make_dir $t/rt/stage$s/$i
done
Expand Down
13 changes: 12 additions & 1 deletion mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,16 @@ RUNTIME_CXXS_$(1)_$(2) := \
rt/rust_android_dummy.cpp \
rt/rust_test_helpers.cpp

RUNTIME_CS_$(1)_$(2) := rt/linenoise/linenoise.c rt/linenoise/utf8.c
RUNTIME_CS_$(1)_$(2) := rt/linenoise/linenoise.c \
rt/linenoise/utf8.c \
rt/sundown/src/autolink.c \
rt/sundown/src/buffer.c \
rt/sundown/src/stack.c \
rt/sundown/src/markdown.c \
rt/sundown/html/houdini_href_e.c \
rt/sundown/html/houdini_html_e.c \
rt/sundown/html/html_smartypants.c \
rt/sundown/html/html.c

RUNTIME_S_$(1)_$(2) := rt/arch/$$(HOST_$(1))/_context.S \
rt/arch/$$(HOST_$(1))/ccall.S \
Expand Down Expand Up @@ -117,6 +126,8 @@ RUNTIME_DEF_$(1)_$(2) := $$(RT_OUTPUT_DIR_$(1))/rustrt$$(CFG_DEF_SUFFIX_$(1))
RUNTIME_INCS_$(1)_$(2) := -I $$(S)src/rt -I $$(S)src/rt/isaac -I $$(S)src/rt/uthash \
-I $$(S)src/rt/arch/$$(HOST_$(1)) \
-I $$(S)src/rt/linenoise \
-I $$(S)src/rt/sundown/src \
-I $$(S)src/rt/sundown/html \
-I $$(S)src/libuv/include
RUNTIME_OBJS_$(1)_$(2) := $$(RUNTIME_CXXS_$(1)_$(2):rt/%.cpp=$$(RT_BUILD_DIR_$(1)_$(2))/%.o) \
$$(RUNTIME_CS_$(1)_$(2):rt/%.c=$$(RT_BUILD_DIR_$(1)_$(2))/%.o) \
Expand Down
7 changes: 5 additions & 2 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,9 @@ ALL_CS := $(wildcard $(S)src/rt/*.cpp \
$(S)src/rt/*/*/*.cpp \
$(S)src/rustllvm/*.cpp)
ALL_CS := $(filter-out $(S)src/rt/miniz.cpp \
$(S)src/rt/linenoise/linenoise.c \
$(S)src/rt/linenoise/utf8.c \
$(wildcard $(S)src/rt/linenoise/*.c) \
$(wildcard $(S)src/rt/sundown/src/*.c) \
$(wildcard $(S)src/rt/sundown/html/*.c) \
,$(ALL_CS))
ALL_HS := $(wildcard $(S)src/rt/*.h \
$(S)src/rt/*/*.h \
Expand All @@ -241,6 +242,8 @@ ALL_HS := $(filter-out $(S)src/rt/vg/valgrind.h \
$(S)src/rt/msvc/inttypes.h \
$(S)src/rt/linenoise/linenoise.h \
$(S)src/rt/linenoise/utf8.h \
$(wildcard $(S)src/rt/sundown/src/*.h) \
$(wildcard $(S)src/rt/sundown/html/*.h) \
,$(ALL_HS))

# Run the tidy script in multiple parts to avoid huge 'echo' commands
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* In this example, a large vector of floats is shared between several tasks.
* With simple pipes, without Arc, a copy would have to be made for each task.
*
* ~~~ {.rust}
* ```rust
* extern mod std;
* use extra::arc;
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
Expand All @@ -34,7 +34,7 @@
* // Work with the local numbers
* }
* }
* ~~~
* ```
*/

#[allow(missing_doc)];
Expand Down Expand Up @@ -440,7 +440,7 @@ impl<T:Freeze + Send> RWArc<T> {
*
* # Example
*
* ~~~ {.rust}
* ```rust
* do arc.write_downgrade |mut write_token| {
* do write_token.write_cond |state, condvar| {
* ... exclusive access with mutable state ...
Expand All @@ -450,7 +450,7 @@ impl<T:Freeze + Send> RWArc<T> {
* ... shared access with immutable state ...
* }
* }
* ~~~
* ```
*/
pub fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
unsafe {
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/base64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ impl<'self> ToBase64 for &'self [u8] {
*
* # Example
*
* ~~~ {.rust}
* ```rust
* extern mod extra;
* use extra::base64::{ToBase64, standard};
*
* fn main () {
* let str = [52,32].to_base64(standard);
* printfln!("%s", str);
* }
* ~~~
* ```
*/
fn to_base64(&self, config: Config) -> ~str {
let bytes = match config.char_set {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl<'self> FromBase64 for &'self str {
*
* This converts a string literal to base64 and back.
*
* ~~~ {.rust}
* ```rust
* extern mod extra;
* use extra::base64::{ToBase64, FromBase64, standard};
* use std::str;
Expand All @@ -183,7 +183,7 @@ impl<'self> FromBase64 for &'self str {
* let result_str = str::from_utf8(bytes);
* printfln!("%s", result_str);
* }
* ~~~
* ```
*/
fn from_base64(&self) -> Result<~[u8], ~str> {
let mut r = ~[];
Expand Down
3 changes: 1 addition & 2 deletions src/libextra/extra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ Rust extras are part of the standard Rust distribution.
url = "https://github.com/mozilla/rust/tree/master/src/libextra")];

#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
passes = "strip-hidden")];
html_favicon_url = "http://www.rust-lang.org/favicon.ico")];

#[comment = "Rust extras"];
#[license = "MIT/ASL2"];
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/flatpipes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ports and channels.

This example sends boxed integers across tasks using serialization.

~~~ {.rust}
```rust
let (port, chan) = serial::pipe_stream();

do task::spawn || {
Expand All @@ -37,7 +37,7 @@ do task::spawn || {
for i in range(0, 10) {
assert @i == port.recv()
}
~~~
```

# Safety Note

Expand Down
4 changes: 2 additions & 2 deletions src/libextra/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
*
* # Example
*
* ~~~ {.rust}
* ```rust
* # fn fib(n: uint) -> uint {42};
* # fn make_a_sandwich() {};
* let mut delayed_fib = extra::future::spawn (|| fib(5000) );
* make_a_sandwich();
* printfln!("fib(5000) = %?", delayed_fib.get())
* ~~~
* ```
*/

#[allow(missing_doc)];
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
//! that requires an input file to be specified, accepts an optional output
//! file name following -o, and accepts both -h and --help as optional flags.
//!
//! ```
//! ~~~{.rust}
//! exter mod extra;
//! use extra::getopts::*;
//! use std::os;
Expand Down Expand Up @@ -75,7 +75,7 @@
//! };
//! do_work(input, output);
//! }
//! ```
//! ~~~

use std::cmp::Eq;
use std::result::{Err, Ok};
Expand Down
16 changes: 8 additions & 8 deletions src/libextra/glob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ pub struct GlobIterator {
* Consider a directory `/media/pictures` containing only the files `kittens.jpg`,
* `puppies.jpg` and `hamsters.gif`:
*
* ~~~ {.rust}
* ```rust
* for path in glob("/media/pictures/*.jpg") {
* println(path.to_str());
* }
* ~~~
* ```
*
* The above code will print:
*
* ~~~
* ```
* /media/pictures/kittens.jpg
* /media/pictures/puppies.jpg
* ~~~
* ```
*/
pub fn glob(pattern: &str) -> GlobIterator {
glob_with(pattern, MatchOptions::new())
Expand Down Expand Up @@ -270,11 +270,11 @@ impl Pattern {
*
* # Example
*
* ~~~ {.rust}
* ```rust
* assert!(Pattern::new("c?t").matches("cat"));
* assert!(Pattern::new("k[!e]tteh").matches("kitteh"));
* assert!(Pattern::new("d*g").matches("doog"));
* ~~~
* ```
*/
pub fn matches(&self, str: &str) -> bool {
self.matches_with(str, MatchOptions::new())
Expand Down Expand Up @@ -492,13 +492,13 @@ impl MatchOptions {
*
* This function always returns this value:
*
* ~~~ {.rust}
* ```rust
* MatchOptions {
* case_sensitive: true,
* require_literal_separator: false.
* require_literal_leading_dot: false
* }
* ~~~
* ```
*/
pub fn new() -> MatchOptions {
MatchOptions {
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ impl<'self> ToHex for &'self [u8] {
*
* # Example
*
* ~~~ {.rust}
* ```rust
* extern mod extra;
* use extra::hex::ToHex;
*
* fn main () {
* let str = [52,32].to_hex();
* printfln!("%s", str);
* }
* ~~~
* ```
*/
fn to_hex(&self) -> ~str {
let mut v = vec::with_capacity(self.len() * 2);
Expand Down Expand Up @@ -70,7 +70,7 @@ impl<'self> FromHex for &'self str {
*
* This converts a string literal to hexadecimal and back.
*
* ~~~ {.rust}
* ```rust
* extern mod extra;
* use extra::hex::{FromHex, ToHex};
* use std::str;
Expand All @@ -83,7 +83,7 @@ impl<'self> FromHex for &'self str {
* let result_str = str::from_utf8(bytes);
* printfln!("%s", result_str);
* }
* ~~~
* ```
*/
fn from_hex(&self) -> Result<~[u8], ~str> {
// This may be an overestimate if there is any whitespace
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ impl RWLock {
*
* # Example
*
* ~~~ {.rust}
* ```rust
* do lock.write_downgrade |mut write_token| {
* do write_token.write_cond |condvar| {
* ... exclusive access ...
Expand All @@ -588,7 +588,7 @@ impl RWLock {
* ... shared access ...
* }
* }
* ~~~
* ```
*/
pub fn write_downgrade<U>(&self, blk: &fn(v: RWLockWriteMode) -> U) -> U {
// Implementation slightly different from the slicker 'write's above.
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ unlikely.

To create a new random (V4) UUID and print it out in hexadecimal form:

~~~ {.rust}
```rust
extern mod extra;
use extra::uuid::Uuid;

fn main() {
let uuid1 = Uuid::new_v4();
println(uuid1.to_str());
}
~~~
```

# Strings

Expand Down
28 changes: 28 additions & 0 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,26 @@ impl Resolver {
assert!(import_resolution.outstanding_references >= 1);
import_resolution.outstanding_references -= 1;

// record what this import resolves to for later uses in documentation,
// this may resolve to either a value or a type, but for documentation
// purposes it's good enough to just favor one over the other.
match i.value_target {
Some(target) => {
self.def_map.insert(i.value_id,
target.bindings.value_def.get_ref().def);
}
None => {}
}
match i.type_target {
Some(target) => {
match target.bindings.type_def.get_ref().type_def {
Some(def) => { self.def_map.insert(i.type_id, def); }
None => {}
}
}
None => {}
}

debug!("(resolving single import) successfully resolved import");
return Success(());
}
Expand Down Expand Up @@ -2626,6 +2646,14 @@ impl Resolver {
merge_import_resolution(name, name_bindings);
}

// Record the destination of this import
match containing_module.def_id {
Some(did) => {
self.def_map.insert(id, DefMod(did));
}
None => {}
}

debug!("(resolving glob import) successfully resolved import");
return Success(());
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/infer/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,4 @@ We make use of a trait-like impementation strategy to consolidate
duplicated code between subtypes, GLB, and LUB computations. See the
section on "Type Combining" below for details.

*/
*/
Loading