rustdoc: Add a primitive page for raw pointers

Closes #15318
This commit is contained in:
Alex Crichton 2015-04-06 15:58:23 -07:00
parent c9c7be78db
commit 9ad133b4a1
10 changed files with 90 additions and 5 deletions

View File

@ -1167,6 +1167,7 @@ fn document(config: &Config, props: &TestProps,
testfile: &Path, extra_args: &[String]) -> (ProcRes, PathBuf) {
let aux_dir = aux_output_dir_name(config, testfile);
let out_dir = output_base_name(config, testfile);
let _ = fs::remove_dir_all(&out_dir);
ensure_dir(&out_dir);
let mut args = vec!["-L".to_string(),
aux_dir.to_str().unwrap().to_string(),

View File

@ -186,7 +186,8 @@ def concat_multi_lines(f):
firstlineno = firstlineno or lineno
if line.endswith('\\'):
lastline = line[:-1]
if lastline is None:
lastline = line[:-1]
catenated += line[:-1]
else:
yield firstlineno, catenated + line

View File

@ -89,6 +89,7 @@
//! of unsafe pointers in Rust.
#![stable(feature = "rust1", since = "1.0.0")]
#![doc(primitive = "pointer")]
use mem;
use clone::Clone;

View File

@ -1368,6 +1368,7 @@ pub enum PrimitiveType {
Slice,
Array,
PrimitiveTuple,
PrimitiveRawPointer,
}
#[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
@ -1404,6 +1405,7 @@ impl PrimitiveType {
"array" => Some(Array),
"slice" => Some(Slice),
"tuple" => Some(PrimitiveTuple),
"pointer" => Some(PrimitiveRawPointer),
_ => None,
}
}
@ -1449,6 +1451,7 @@ impl PrimitiveType {
Array => "array",
Slice => "slice",
PrimitiveTuple => "tuple",
PrimitiveRawPointer => "pointer",
}
}

View File

@ -491,7 +491,8 @@ impl fmt::Display for clean::Type {
}
clean::Bottom => f.write_str("!"),
clean::RawPointer(m, ref t) => {
write!(f, "*{}{}", RawMutableSpace(m), **t)
primitive_link(f, clean::PrimitiveType::PrimitiveRawPointer,
&format!("*{}{}", RawMutableSpace(m), **t))
}
clean::BorrowedRef{ lifetime: ref l, mutability, type_: ref ty} => {
let lt = match *l {

View File

@ -1028,7 +1028,8 @@ impl DocFolder for Cache {
clean::Item{ attrs, inner: clean::ImplItem(i), .. } => {
use clean::{Primitive, Vector, ResolvedPath, BorrowedRef};
use clean::PrimitiveType::{Array, Slice, PrimitiveTuple};
use clean::{FixedVector, Tuple};
use clean::PrimitiveType::{PrimitiveRawPointer};
use clean::{FixedVector, Tuple, RawPointer};
// extract relevant documentation for this impl
let dox = match attrs.into_iter().find(|a| {
@ -1064,8 +1065,8 @@ impl DocFolder for Cache {
Some(ast_util::local_def(Array.to_node_id()))
}
// In a DST world, we may only need Vector, but for now we
// also pick up borrowed references
// In a DST world, we may only need Vector, but for
// now we also pick up borrowed references
Vector(..) |
BorrowedRef{ type_: box Vector(..), .. } =>
{
@ -1077,6 +1078,11 @@ impl DocFolder for Cache {
Some(ast_util::local_def(id))
}
RawPointer(..) => {
let id = PrimitiveRawPointer.to_node_id();
Some(ast_util::local_def(id))
}
_ => None,
};

View File

@ -0,0 +1,15 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![doc(html_root_url = "http://example.com/")]
/// dox
#[doc(primitive = "pointer")]
pub mod ptr {}

View File

@ -0,0 +1,21 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:issue-15318.rs
extern crate issue_15318;
pub use issue_15318::ptr;
// @has issue_15318_2/fn.bar.html \
// '//*[@href="primitive.pointer.html"]' \
// '*mut T'
pub fn bar<T>(ptr: *mut T) {}

View File

@ -0,0 +1,15 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// @has issue_15318_3/primitive.pointer.html
/// dox
#[doc(primitive = "pointer")]
pub mod ptr {}

View File

@ -0,0 +1,21 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:issue-15318.rs
#![feature(no_std)]
#![no_std]
extern crate issue_15318;
// @has issue_15318/fn.bar.html \
// '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \
// '*mut T'
pub fn bar<T>(ptr: *mut T) {}