rustdoc: Support for "array" primitive
Impls on `clean::Type::FixedVector` are now collected in the array primitive page instead of the slice primitive page. Also add a primitive docs for arrays to `std`.
This commit is contained in:
parent
b0aad7dd4f
commit
2df8830642
6 changed files with 38 additions and 10 deletions
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
#![unstable(feature = "core")] // not yet reviewed
|
#![unstable(feature = "core")] // not yet reviewed
|
||||||
|
|
||||||
|
#![doc(primitive = "array")]
|
||||||
|
|
||||||
use clone::Clone;
|
use clone::Clone;
|
||||||
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
|
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
|
||||||
use fmt;
|
use fmt;
|
||||||
|
|
|
@ -1322,7 +1322,8 @@ pub enum Type {
|
||||||
/// For parameterized types, so the consumer of the JSON don't go
|
/// For parameterized types, so the consumer of the JSON don't go
|
||||||
/// looking for types which don't exist anywhere.
|
/// looking for types which don't exist anywhere.
|
||||||
Generic(String),
|
Generic(String),
|
||||||
/// Primitives are just the fixed-size numeric types (plus int/uint/float), and char.
|
/// Primitives are the fixed-size numeric types (plus int/uint/float), char,
|
||||||
|
/// arrays, slices, and tuples.
|
||||||
Primitive(PrimitiveType),
|
Primitive(PrimitiveType),
|
||||||
/// extern "ABI" fn
|
/// extern "ABI" fn
|
||||||
BareFunction(Box<BareFunctionDecl>),
|
BareFunction(Box<BareFunctionDecl>),
|
||||||
|
@ -1362,6 +1363,7 @@ pub enum PrimitiveType {
|
||||||
Bool,
|
Bool,
|
||||||
Str,
|
Str,
|
||||||
Slice,
|
Slice,
|
||||||
|
Array,
|
||||||
PrimitiveTuple,
|
PrimitiveTuple,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1396,6 +1398,7 @@ impl PrimitiveType {
|
||||||
"str" => Some(Str),
|
"str" => Some(Str),
|
||||||
"f32" => Some(F32),
|
"f32" => Some(F32),
|
||||||
"f64" => Some(F64),
|
"f64" => Some(F64),
|
||||||
|
"array" => Some(Array),
|
||||||
"slice" => Some(Slice),
|
"slice" => Some(Slice),
|
||||||
"tuple" => Some(PrimitiveTuple),
|
"tuple" => Some(PrimitiveTuple),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -1440,6 +1443,7 @@ impl PrimitiveType {
|
||||||
Str => "str",
|
Str => "str",
|
||||||
Bool => "bool",
|
Bool => "bool",
|
||||||
Char => "char",
|
Char => "char",
|
||||||
|
Array => "array",
|
||||||
Slice => "slice",
|
Slice => "slice",
|
||||||
PrimitiveTuple => "tuple",
|
PrimitiveTuple => "tuple",
|
||||||
}
|
}
|
||||||
|
|
|
@ -486,7 +486,7 @@ impl fmt::Display for clean::Type {
|
||||||
primitive_link(f, clean::Slice, &format!("[{}]", **t))
|
primitive_link(f, clean::Slice, &format!("[{}]", **t))
|
||||||
}
|
}
|
||||||
clean::FixedVector(ref t, ref s) => {
|
clean::FixedVector(ref t, ref s) => {
|
||||||
primitive_link(f, clean::Slice,
|
primitive_link(f, clean::PrimitiveType::Array,
|
||||||
&format!("[{}; {}]", **t, *s))
|
&format!("[{}; {}]", **t, *s))
|
||||||
}
|
}
|
||||||
clean::Bottom => f.write_str("!"),
|
clean::Bottom => f.write_str("!"),
|
||||||
|
|
|
@ -1026,7 +1026,8 @@ impl DocFolder for Cache {
|
||||||
match item {
|
match item {
|
||||||
clean::Item{ attrs, inner: clean::ImplItem(i), .. } => {
|
clean::Item{ attrs, inner: clean::ImplItem(i), .. } => {
|
||||||
use clean::{Primitive, Vector, ResolvedPath, BorrowedRef};
|
use clean::{Primitive, Vector, ResolvedPath, BorrowedRef};
|
||||||
use clean::{FixedVector, Slice, Tuple, PrimitiveTuple};
|
use clean::PrimitiveType::{Array, Slice, PrimitiveTuple};
|
||||||
|
use clean::{FixedVector, Tuple};
|
||||||
|
|
||||||
// extract relevant documentation for this impl
|
// extract relevant documentation for this impl
|
||||||
let dox = match attrs.into_iter().find(|a| {
|
let dox = match attrs.into_iter().find(|a| {
|
||||||
|
@ -1056,12 +1057,16 @@ impl DocFolder for Cache {
|
||||||
Some(ast_util::local_def(p.to_node_id()))
|
Some(ast_util::local_def(p.to_node_id()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// In a DST world, we may only need
|
FixedVector(..) |
|
||||||
// Vector/FixedVector, but for now we also pick up
|
BorrowedRef { type_: box FixedVector(..), .. } =>
|
||||||
// borrowed references
|
{
|
||||||
Vector(..) | FixedVector(..) |
|
Some(ast_util::local_def(Array.to_node_id()))
|
||||||
BorrowedRef{ type_: box Vector(..), .. } |
|
}
|
||||||
BorrowedRef{ type_: box FixedVector(..), .. } =>
|
|
||||||
|
// In a DST world, we may only need Vector, but for now we
|
||||||
|
// also pick up borrowed references
|
||||||
|
Vector(..) |
|
||||||
|
BorrowedRef{ type_: box Vector(..), .. } =>
|
||||||
{
|
{
|
||||||
Some(ast_util::local_def(Slice.to_node_id()))
|
Some(ast_util::local_def(Slice.to_node_id()))
|
||||||
}
|
}
|
||||||
|
|
13
src/libstd/array.rs
Normal file
13
src/libstd/array.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
//! The fixed-size array type (`[T; n]`).
|
||||||
|
|
||||||
|
#![doc(primitive = "array")]
|
|
@ -212,6 +212,9 @@ pub mod prelude;
|
||||||
|
|
||||||
/* Primitive types */
|
/* Primitive types */
|
||||||
|
|
||||||
|
// NB: slice and str are primitive types too, but their module docs + primitive doc pages
|
||||||
|
// are inlined from the public re-exports of core_collections::{slice, str} above.
|
||||||
|
|
||||||
#[path = "num/float_macros.rs"]
|
#[path = "num/float_macros.rs"]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod float_macros;
|
mod float_macros;
|
||||||
|
@ -285,8 +288,9 @@ pub mod sync;
|
||||||
pub mod rt;
|
pub mod rt;
|
||||||
mod panicking;
|
mod panicking;
|
||||||
|
|
||||||
// Documentation for primitive types
|
// Modules that exist purely to document + host impl docs for primitive types
|
||||||
|
|
||||||
|
mod array;
|
||||||
mod bool;
|
mod bool;
|
||||||
mod unit;
|
mod unit;
|
||||||
mod tuple;
|
mod tuple;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue