1
Fork 0

libextra: Require documentation by default

This commit is contained in:
Alex Crichton 2013-05-28 22:11:41 -05:00
parent 007651cd26
commit 395685079a
41 changed files with 113 additions and 7 deletions

View file

@ -37,6 +37,8 @@
* ~~~ * ~~~
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use sync; use sync;

View file

@ -32,6 +32,8 @@
// overhead when initializing plain-old-data and means we don't need // overhead when initializing plain-old-data and means we don't need
// to waste time running the destructors of POD. // to waste time running the destructors of POD.
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use list::{MutList, MutCons, MutNil}; use list::{MutList, MutCons, MutNil};

View file

@ -15,7 +15,10 @@ use core::prelude::*;
use core::str; use core::str;
use core::vec; use core::vec;
/// A trait for converting a value to base64 encoding.
pub trait ToBase64 { pub trait ToBase64 {
/// Converts the value of `self` to a base64 value, returning the owned
/// string
fn to_base64(&self) -> ~str; fn to_base64(&self) -> ~str;
} }
@ -112,6 +115,7 @@ impl<'self> ToBase64 for &'self str {
} }
} }
#[allow(missing_doc)]
pub trait FromBase64 { pub trait FromBase64 {
fn from_base64(&self) -> ~[u8]; fn from_base64(&self) -> ~[u8];
} }

View file

@ -211,9 +211,11 @@ enum BitvVariant { Big(~BigBitv), Small(~SmallBitv) }
enum Op {Union, Intersect, Assign, Difference} enum Op {Union, Intersect, Assign, Difference}
// The bitvector type /// The bitvector type
pub struct Bitv { pub struct Bitv {
/// Internal representation of the bit vector (small or large)
rep: BitvVariant, rep: BitvVariant,
/// The number of valid bits in the internal representation
nbits: uint nbits: uint
} }

View file

@ -10,6 +10,8 @@
//! Unsafe debugging functions for inspecting values. //! Unsafe debugging functions for inspecting values.
#[allow(missing_doc)];
use core::cast::transmute; use core::cast::transmute;
use core::sys; use core::sys;

View file

@ -18,6 +18,7 @@ use core::vec;
static initial_capacity: uint = 32u; // 2^5 static initial_capacity: uint = 32u; // 2^5
#[allow(missing_doc)]
pub struct Deque<T> { pub struct Deque<T> {
priv nelts: uint, priv nelts: uint,
priv lo: uint, priv lo: uint,

View file

@ -26,6 +26,7 @@ use core::vec;
pub type DListLink<T> = Option<@mut DListNode<T>>; pub type DListLink<T> = Option<@mut DListNode<T>>;
#[allow(missing_doc)]
pub struct DListNode<T> { pub struct DListNode<T> {
data: T, data: T,
linked: bool, // for assertions linked: bool, // for assertions
@ -33,6 +34,7 @@ pub struct DListNode<T> {
next: DListLink<T>, next: DListLink<T>,
} }
#[allow(missing_doc)]
pub struct DList<T> { pub struct DList<T> {
size: uint, size: uint,
hd: DListLink<T>, hd: DListLink<T>,
@ -106,6 +108,7 @@ pub fn from_elem<T>(data: T) -> @mut DList<T> {
list list
} }
/// Creates a new dlist from a vector of elements, maintaining the same order
pub fn from_vec<T:Copy>(vec: &[T]) -> @mut DList<T> { pub fn from_vec<T:Copy>(vec: &[T]) -> @mut DList<T> {
do vec::foldl(DList(), vec) |list,data| { do vec::foldl(DList(), vec) |list,data| {
list.push(*data); // Iterating left-to-right -- add newly to the tail. list.push(*data); // Iterating left-to-right -- add newly to the tail.

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
// Simple Extensible Binary Markup Language (ebml) reader and writer on a // Simple Extensible Binary Markup Language (ebml) reader and writer on a

View file

@ -94,6 +94,8 @@ total line count).
} }
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::io::ReaderUtil; use core::io::ReaderUtil;

View file

@ -14,6 +14,8 @@ Simple compression
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::libc::{c_void, size_t, c_int}; use core::libc::{c_void, size_t, c_int};

View file

@ -47,6 +47,8 @@ block the scheduler thread, so will their pipes.
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
// The basic send/recv interface FlatChan and PortChan will implement // The basic send/recv interface FlatChan and PortChan will implement

View file

@ -23,6 +23,8 @@
* ~~~ * ~~~
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::cast; use core::cast;

View file

@ -78,6 +78,8 @@
* ``` * ```
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::cmp::Eq; use core::cmp::Eq;

View file

@ -11,12 +11,16 @@
use core::io::{Reader, BytesReader}; use core::io::{Reader, BytesReader};
use core::io; use core::io;
/// An implementation of the io::Reader interface which reads a buffer of bytes
pub struct BufReader { pub struct BufReader {
/// The buffer of bytes to read
buf: ~[u8], buf: ~[u8],
/// The current position in the buffer of bytes
pos: @mut uint pos: @mut uint
} }
pub impl BufReader { impl BufReader {
/// Creates a new buffer reader for the specified buffer
pub fn new(v: ~[u8]) -> BufReader { pub fn new(v: ~[u8]) -> BufReader {
BufReader { BufReader {
buf: v, buf: v,
@ -24,7 +28,7 @@ pub impl BufReader {
} }
} }
priv fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A { fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
// Recreating the BytesReader state every call since // Recreating the BytesReader state every call since
// I can't get the borrowing to work correctly // I can't get the borrowing to work correctly
let bytes_reader = BytesReader { let bytes_reader = BytesReader {

View file

@ -43,9 +43,14 @@ pub type List = ~[Json];
pub type Object = HashMap<~str, Json>; pub type Object = HashMap<~str, Json>;
#[deriving(Eq)] #[deriving(Eq)]
/// If an error occurs while parsing some JSON, this is the structure which is
/// returned
pub struct Error { pub struct Error {
/// The line number at which the error occurred
line: uint, line: uint,
/// The column number at which the error occurred
col: uint, col: uint,
/// A message describing the type of the error
msg: @~str, msg: @~str,
} }
@ -75,10 +80,13 @@ fn spaces(n: uint) -> ~str {
return ss; return ss;
} }
/// A structure for implementing serialization to JSON.
pub struct Encoder { pub struct Encoder {
priv wr: @io::Writer, priv wr: @io::Writer,
} }
/// Creates a new JSON encoder whose output will be written to the writer
/// specified.
pub fn Encoder(wr: @io::Writer) -> Encoder { pub fn Encoder(wr: @io::Writer) -> Encoder {
Encoder { Encoder {
wr: wr wr: wr
@ -228,11 +236,14 @@ impl serialize::Encoder for Encoder {
} }
} }
/// Another encoder for JSON, but prints out human-readable JSON instead of
/// compact data
pub struct PrettyEncoder { pub struct PrettyEncoder {
priv wr: @io::Writer, priv wr: @io::Writer,
priv indent: uint, priv indent: uint,
} }
/// Creates a new encoder whose output will be written to the specified writer
pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder { pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder {
PrettyEncoder { PrettyEncoder {
wr: wr, wr: wr,
@ -468,6 +479,7 @@ pub fn to_pretty_str(json: &Json) -> ~str {
io::with_str_writer(|wr| to_pretty_writer(wr, json)) io::with_str_writer(|wr| to_pretty_writer(wr, json))
} }
#[allow(missing_doc)]
pub struct Parser { pub struct Parser {
priv rdr: @io::Reader, priv rdr: @io::Reader,
priv ch: char, priv ch: char,
@ -846,10 +858,12 @@ pub fn from_str(s: &str) -> Result<Json, Error> {
} }
} }
/// A structure to decode JSON to values in rust.
pub struct Decoder { pub struct Decoder {
priv stack: ~[Json], priv stack: ~[Json],
} }
/// Creates a new decoder instance for decoding the specified JSON value.
pub fn Decoder(json: Json) -> Decoder { pub fn Decoder(json: Json) -> Decoder {
Decoder { Decoder {
stack: ~[json] stack: ~[json]
@ -1200,7 +1214,11 @@ impl Ord for Json {
fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) } fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) }
} }
trait ToJson { fn to_json(&self) -> Json; } /// A trait for converting values to JSON
trait ToJson {
/// Converts the value of `self` to an instance of JSON
fn to_json(&self) -> Json;
}
impl ToJson for Json { impl ToJson for Json {
fn to_json(&self) -> Json { copy *self } fn to_json(&self) -> Json { copy *self }

View file

@ -21,6 +21,8 @@ struct Quad {
d: u32 d: u32
} }
/// Calculates the md4 hash of the given slice of bytes, returning the 128-bit
/// result as a quad of u32's
pub fn md4(msg: &[u8]) -> Quad { pub fn md4(msg: &[u8]) -> Quad {
// subtle: if orig_len is merely uint, then the code below // subtle: if orig_len is merely uint, then the code below
// which performs shifts by 32 bits or more has undefined // which performs shifts by 32 bits or more has undefined
@ -105,6 +107,8 @@ pub fn md4(msg: &[u8]) -> Quad {
return Quad {a: a, b: b, c: c, d: d}; return Quad {a: a, b: b, c: c, d: d};
} }
/// Calculates the md4 hash of a slice of bytes, returning the hex-encoded
/// version of the hash
pub fn md4_str(msg: &[u8]) -> ~str { pub fn md4_str(msg: &[u8]) -> ~str {
let Quad {a, b, c, d} = md4(msg); let Quad {a, b, c, d} = md4(msg);
fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) { fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) {
@ -123,6 +127,8 @@ pub fn md4_str(msg: &[u8]) -> ~str {
result result
} }
/// Calculates the md4 hash of a string, returning the hex-encoded version of
/// the hash
pub fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) } pub fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) }
#[test] #[test]

View file

@ -10,6 +10,8 @@
//! Types/fns concerning Internet Protocol (IP), versions 4 & 6 //! Types/fns concerning Internet Protocol (IP), versions 4 & 6
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::libc; use core::libc;

View file

@ -11,6 +11,8 @@
//! High-level interface to libuv's TCP functionality //! High-level interface to libuv's TCP functionality
// FIXME #4425: Need FFI fixes // FIXME #4425: Need FFI fixes
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use future; use future;

View file

@ -10,6 +10,8 @@
//! Types/fns concerning URLs (see RFC 3986) //! Types/fns concerning URLs (see RFC 3986)
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::cmp::Eq; use core::cmp::Eq;

View file

@ -597,6 +597,8 @@ impl BigUint {
} }
/// Converts this big integer into a uint, returning the uint::max_value if
/// it's too large to fit in a uint.
pub fn to_uint(&self) -> uint { pub fn to_uint(&self) -> uint {
match self.data.len() { match self.data.len() {
0 => 0, 0 => 0,

View file

@ -25,7 +25,9 @@ use core::num::{Zero,One,ToStrRadix};
/// A complex number in Cartesian form. /// A complex number in Cartesian form.
#[deriving(Eq,Clone)] #[deriving(Eq,Clone)]
pub struct Cmplx<T> { pub struct Cmplx<T> {
/// Real portion of the complex number
re: T, re: T,
/// Imaginary portion of the complex number
im: T im: T
} }

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
//! Rational numbers //! Rational numbers
use core::prelude::*; use core::prelude::*;
@ -22,6 +21,7 @@ use super::bigint::BigInt;
/// Represents the ratio between 2 numbers. /// Represents the ratio between 2 numbers.
#[deriving(Clone)] #[deriving(Clone)]
#[allow(missing_doc)]
pub struct Ratio<T> { pub struct Ratio<T> {
numer: T, numer: T,
denom: T denom: T
@ -49,7 +49,7 @@ impl<T: Clone + Integer + Ord>
Ratio { numer: numer, denom: denom } Ratio { numer: numer, denom: denom }
} }
// Create a new Ratio. Fails if `denom == 0`. /// Create a new Ratio. Fails if `denom == 0`.
#[inline(always)] #[inline(always)]
pub fn new(numer: T, denom: T) -> Ratio<T> { pub fn new(numer: T, denom: T) -> Ratio<T> {
if denom == Zero::zero() { if denom == Zero::zero() {

View file

@ -17,6 +17,7 @@ use core::unstable::intrinsics::{move_val_init, init};
use core::util::{replace, swap}; use core::util::{replace, swap};
use core::vec; use core::vec;
#[allow(missing_doc)]
pub struct PriorityQueue<T> { pub struct PriorityQueue<T> {
priv data: ~[T], priv data: ~[T],
} }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[allow(missing_doc)];
/** Task-local reference counted smart pointers /** Task-local reference counted smart pointers
Task-local reference counted smart pointers are an alternative to managed boxes with deterministic Task-local reference counted smart pointers are an alternative to managed boxes with deterministic

View file

@ -33,6 +33,8 @@
* * access to a character by index is logarithmic (linear in strings); * * access to a character by index is logarithmic (linear in strings);
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::str; use core::str;

View file

@ -10,6 +10,8 @@
//! Semver parsing and logic //! Semver parsing and logic
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::char; use core::char;

View file

@ -14,6 +14,7 @@
Core encoding and decoding interfaces. Core encoding and decoding interfaces.
*/ */
#[allow(missing_doc)];
#[forbid(non_camel_case_types)]; #[forbid(non_camel_case_types)];
use core::prelude::*; use core::prelude::*;

View file

@ -23,6 +23,7 @@ use core::uint;
use core::util::replace; use core::util::replace;
use core::vec; use core::vec;
#[allow(missing_doc)]
pub struct SmallIntMap<T> { pub struct SmallIntMap<T> {
priv v: ~[Option<T>], priv v: ~[Option<T>],
} }
@ -186,6 +187,9 @@ pub impl<V:Copy> SmallIntMap<V> {
} }
} }
/// A set implemented on top of the SmallIntMap type. This set is always a set
/// of integers, and the space requirements are on the order of the highest
/// valued integer in the set.
pub struct SmallIntSet { pub struct SmallIntSet {
priv map: SmallIntMap<()> priv map: SmallIntMap<()>
} }

View file

@ -167,6 +167,7 @@ pub fn quick_sort3<T:Copy + Ord + Eq>(arr: &mut [T]) {
qsort3(arr, 0, (len - 1) as int); qsort3(arr, 0, (len - 1) as int);
} }
#[allow(missing_doc)]
pub trait Sort { pub trait Sort {
fn qsort(self); fn qsort(self);
} }
@ -179,6 +180,7 @@ static MIN_MERGE: uint = 64;
static MIN_GALLOP: uint = 7; static MIN_GALLOP: uint = 7;
static INITIAL_TMP_STORAGE: uint = 128; static INITIAL_TMP_STORAGE: uint = 128;
#[allow(missing_doc)]
pub fn tim_sort<T:Copy + Ord>(array: &mut [T]) { pub fn tim_sort<T:Copy + Ord>(array: &mut [T]) {
let size = array.len(); let size = array.len();
if size < 2 { if size < 2 {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::vec; use core::vec;

View file

@ -27,8 +27,12 @@ not required in or otherwise suitable for the core library.
#[crate_type = "lib"]; #[crate_type = "lib"];
#[deny(non_camel_case_types)]; #[deny(non_camel_case_types)];
#[deny(missing_doc)];
// NOTE: remove these two attributes after the next snapshot
#[no_core]; // for stage0
#[allow(unrecognized_lint)]; // otherwise stage0 is seriously ugly
#[no_core];
#[no_std]; #[no_std];
extern mod core(name = "std", vers = "0.7-pre"); extern mod core(name = "std", vers = "0.7-pre");

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[allow(missing_doc)];
/// A task pool abstraction. Useful for achieving predictable CPU /// A task pool abstraction. Useful for achieving predictable CPU
/// parallelism. /// parallelism.

View file

@ -16,6 +16,8 @@ use core::os;
use core::rand::RngUtil; use core::rand::RngUtil;
use core::rand; use core::rand;
/// Attempts to make a temporary directory inside of `tmpdir` whose name will
/// have the suffix `suffix`. If no directory can be created, None is returned.
pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> { pub fn mkdtemp(tmpdir: &Path, suffix: &str) -> Option<Path> {
let mut r = rand::rng(); let mut r = rand::rng();
for 1000.times { for 1000.times {

View file

@ -10,6 +10,8 @@
//! Simple ANSI color library //! Simple ANSI color library
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::io; use core::io;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use core::i32; use core::i32;

View file

@ -34,6 +34,7 @@ use core::util::{swap, replace};
// * union: | // * union: |
// These would be convenient since the methods work like `each` // These would be convenient since the methods work like `each`
#[allow(missing_doc)]
pub struct TreeMap<K, V> { pub struct TreeMap<K, V> {
priv root: Option<~TreeNode<K, V>>, priv root: Option<~TreeNode<K, V>>,
priv length: uint priv length: uint
@ -242,6 +243,9 @@ impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> {
} }
} }
/// A implementation of the `Set` trait on top of the `TreeMap` container. The
/// only requirement is that the type of the elements contained ascribes to the
/// `TotalOrd` trait.
pub struct TreeSet<T> { pub struct TreeSet<T> {
priv map: TreeMap<T, ()> priv map: TreeMap<T, ()>
} }

View file

@ -9,6 +9,7 @@
// except according to those terms. // except according to those terms.
#[forbid(deprecated_mode)]; #[forbid(deprecated_mode)];
#[allow(missing_doc)];
pub mod icu { pub mod icu {
pub type UBool = u8; pub type UBool = u8;

View file

@ -15,6 +15,8 @@
* `interact` function you can execute code in a uv callback. * `interact` function you can execute code in a uv callback.
*/ */
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use ll = uv_ll; use ll = uv_ll;

View file

@ -31,6 +31,7 @@
*/ */
#[allow(non_camel_case_types)]; // C types #[allow(non_camel_case_types)]; // C types
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#[allow(missing_doc)];
use core::prelude::*; use core::prelude::*;
use json; use json;

View file

@ -10,6 +10,8 @@
//! Process spawning. //! Process spawning.
#[allow(missing_doc)];
use cast; use cast;
use comm::{stream, SharedChan, GenericChan, GenericPort}; use comm::{stream, SharedChan, GenericChan, GenericPort};
use int; use int;