Skip to content

Commit ca74cbd

Browse files
committed
auto merge of #6798 : alexcrichton/rust/doc-lints, r=pcwalton
These commits perform a variety of actions: 1. The linting of missing documentation has been consolidated under one `missing_doc` attribute, and many more things are linted about. 2. A test was added for linting missing documentation, which revealed a large number of corner cases in both linting and the `missing_doc` lint pass. Some notable edge cases: * When compiling with `--test`, all `missing_doc` warnings are suppressed * If any parent of the current item has `#[doc(hidden)]`, then the `missing_doc` warning is suppressed 3. Both the std and extra libraries were modified to `#[deny(missing_doc)]` by default. I believe that the libraries are getting to the point where they're fairly well documented, and they should definitely stay that way. If developing a particular new module, it's easy enough to add `#[allow(missing_doc)]` at the top, but those should definitely be flags for removal in favor of actual documentation. I added as much documentation as I could throughout std/extra, although I avoided trying to document things that I knew nothing about. I can't say that this lint pass will vouch for the quality of the documentation of std/extra, but it will certainly make sure that there's at least some describing words. That being said, I may have a different opinion, so I don't mind amending these commits to turn off the lint by default for std/extra if people think otherwise.
2 parents 31b2804 + 3956850 commit ca74cbd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1035
-151
lines changed

src/libextra/arc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
* ~~~
3838
*/
3939

40+
#[allow(missing_doc)];
41+
4042
use core::prelude::*;
4143

4244
use sync;

src/libextra/arena.rs

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
// overhead when initializing plain-old-data and means we don't need
3333
// to waste time running the destructors of POD.
3434

35+
#[allow(missing_doc)];
36+
3537
use core::prelude::*;
3638

3739
use list::{MutList, MutCons, MutNil};

src/libextra/base64.rs

+4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ use core::prelude::*;
1515
use core::str;
1616
use core::vec;
1717

18+
/// A trait for converting a value to base64 encoding.
1819
pub trait ToBase64 {
20+
/// Converts the value of `self` to a base64 value, returning the owned
21+
/// string
1922
fn to_base64(&self) -> ~str;
2023
}
2124

@@ -112,6 +115,7 @@ impl<'self> ToBase64 for &'self str {
112115
}
113116
}
114117

118+
#[allow(missing_doc)]
115119
pub trait FromBase64 {
116120
fn from_base64(&self) -> ~[u8];
117121
}

src/libextra/bitv.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ enum BitvVariant { Big(~BigBitv), Small(~SmallBitv) }
211211

212212
enum Op {Union, Intersect, Assign, Difference}
213213

214-
// The bitvector type
214+
/// The bitvector type
215215
pub struct Bitv {
216+
/// Internal representation of the bit vector (small or large)
216217
rep: BitvVariant,
218+
/// The number of valid bits in the internal representation
217219
nbits: uint
218220
}
219221

src/libextra/dbg.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Unsafe debugging functions for inspecting values.
1212
13+
#[allow(missing_doc)];
14+
1315
use core::cast::transmute;
1416
use core::sys;
1517

src/libextra/deque.rs

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use core::vec;
1818

1919
static initial_capacity: uint = 32u; // 2^5
2020

21+
#[allow(missing_doc)]
2122
pub struct Deque<T> {
2223
priv nelts: uint,
2324
priv lo: uint,

src/libextra/dlist.rs

+3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ use core::vec;
2626

2727
pub type DListLink<T> = Option<@mut DListNode<T>>;
2828

29+
#[allow(missing_doc)]
2930
pub struct DListNode<T> {
3031
data: T,
3132
linked: bool, // for assertions
3233
prev: DListLink<T>,
3334
next: DListLink<T>,
3435
}
3536

37+
#[allow(missing_doc)]
3638
pub struct DList<T> {
3739
size: uint,
3840
hd: DListLink<T>,
@@ -106,6 +108,7 @@ pub fn from_elem<T>(data: T) -> @mut DList<T> {
106108
list
107109
}
108110

111+
/// Creates a new dlist from a vector of elements, maintaining the same order
109112
pub fn from_vec<T:Copy>(vec: &[T]) -> @mut DList<T> {
110113
do vec::foldl(DList(), vec) |list,data| {
111114
list.push(*data); // Iterating left-to-right -- add newly to the tail.

src/libextra/ebml.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(missing_doc)];
12+
1113
use core::prelude::*;
1214

1315
// Simple Extensible Binary Markup Language (ebml) reader and writer on a

src/libextra/fileinput.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ total line count).
9494
}
9595
*/
9696

97+
#[allow(missing_doc)];
98+
9799
use core::prelude::*;
98100

99101
use core::io::ReaderUtil;

src/libextra/flate.rs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Simple compression
1414
1515
*/
1616

17+
#[allow(missing_doc)];
18+
1719
use core::prelude::*;
1820

1921
use core::libc::{c_void, size_t, c_int};

src/libextra/flatpipes.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ block the scheduler thread, so will their pipes.
4747
4848
*/
4949

50+
#[allow(missing_doc)];
51+
5052
use core::prelude::*;
5153

5254
// The basic send/recv interface FlatChan and PortChan will implement

src/libextra/future.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* ~~~
2424
*/
2525

26+
#[allow(missing_doc)];
27+
2628
use core::prelude::*;
2729

2830
use core::cast;

src/libextra/getopts.rs

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
* ```
7979
*/
8080

81+
#[allow(missing_doc)];
82+
8183
use core::prelude::*;
8284

8385
use core::cmp::Eq;

src/libextra/io_util.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,24 @@
1111
use core::io::{Reader, BytesReader};
1212
use core::io;
1313

14+
/// An implementation of the io::Reader interface which reads a buffer of bytes
1415
pub struct BufReader {
16+
/// The buffer of bytes to read
1517
buf: ~[u8],
18+
/// The current position in the buffer of bytes
1619
pos: @mut uint
1720
}
1821

19-
pub impl BufReader {
22+
impl BufReader {
23+
/// Creates a new buffer reader for the specified buffer
2024
pub fn new(v: ~[u8]) -> BufReader {
2125
BufReader {
2226
buf: v,
2327
pos: @mut 0
2428
}
2529
}
2630

27-
priv fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
31+
fn as_bytes_reader<A>(&self, f: &fn(&BytesReader) -> A) -> A {
2832
// Recreating the BytesReader state every call since
2933
// I can't get the borrowing to work correctly
3034
let bytes_reader = BytesReader {

src/libextra/json.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@ pub type List = ~[Json];
4343
pub type Object = HashMap<~str, Json>;
4444

4545
#[deriving(Eq)]
46+
/// If an error occurs while parsing some JSON, this is the structure which is
47+
/// returned
4648
pub struct Error {
49+
/// The line number at which the error occurred
4750
line: uint,
51+
/// The column number at which the error occurred
4852
col: uint,
53+
/// A message describing the type of the error
4954
msg: @~str,
5055
}
5156

@@ -75,10 +80,13 @@ fn spaces(n: uint) -> ~str {
7580
return ss;
7681
}
7782

83+
/// A structure for implementing serialization to JSON.
7884
pub struct Encoder {
7985
priv wr: @io::Writer,
8086
}
8187

88+
/// Creates a new JSON encoder whose output will be written to the writer
89+
/// specified.
8290
pub fn Encoder(wr: @io::Writer) -> Encoder {
8391
Encoder {
8492
wr: wr
@@ -228,11 +236,14 @@ impl serialize::Encoder for Encoder {
228236
}
229237
}
230238

239+
/// Another encoder for JSON, but prints out human-readable JSON instead of
240+
/// compact data
231241
pub struct PrettyEncoder {
232242
priv wr: @io::Writer,
233243
priv indent: uint,
234244
}
235245

246+
/// Creates a new encoder whose output will be written to the specified writer
236247
pub fn PrettyEncoder(wr: @io::Writer) -> PrettyEncoder {
237248
PrettyEncoder {
238249
wr: wr,
@@ -468,6 +479,7 @@ pub fn to_pretty_str(json: &Json) -> ~str {
468479
io::with_str_writer(|wr| to_pretty_writer(wr, json))
469480
}
470481

482+
#[allow(missing_doc)]
471483
pub struct Parser {
472484
priv rdr: @io::Reader,
473485
priv ch: char,
@@ -846,10 +858,12 @@ pub fn from_str(s: &str) -> Result<Json, Error> {
846858
}
847859
}
848860

861+
/// A structure to decode JSON to values in rust.
849862
pub struct Decoder {
850863
priv stack: ~[Json],
851864
}
852865

866+
/// Creates a new decoder instance for decoding the specified JSON value.
853867
pub fn Decoder(json: Json) -> Decoder {
854868
Decoder {
855869
stack: ~[json]
@@ -1200,7 +1214,11 @@ impl Ord for Json {
12001214
fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) }
12011215
}
12021216

1203-
trait ToJson { fn to_json(&self) -> Json; }
1217+
/// A trait for converting values to JSON
1218+
trait ToJson {
1219+
/// Converts the value of `self` to an instance of JSON
1220+
fn to_json(&self) -> Json;
1221+
}
12041222

12051223
impl ToJson for Json {
12061224
fn to_json(&self) -> Json { copy *self }

src/libextra/md4.rs

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ struct Quad {
2121
d: u32
2222
}
2323

24+
/// Calculates the md4 hash of the given slice of bytes, returning the 128-bit
25+
/// result as a quad of u32's
2426
pub fn md4(msg: &[u8]) -> Quad {
2527
// subtle: if orig_len is merely uint, then the code below
2628
// which performs shifts by 32 bits or more has undefined
@@ -105,6 +107,8 @@ pub fn md4(msg: &[u8]) -> Quad {
105107
return Quad {a: a, b: b, c: c, d: d};
106108
}
107109

110+
/// Calculates the md4 hash of a slice of bytes, returning the hex-encoded
111+
/// version of the hash
108112
pub fn md4_str(msg: &[u8]) -> ~str {
109113
let Quad {a, b, c, d} = md4(msg);
110114
fn app(a: u32, b: u32, c: u32, d: u32, f: &fn(u32)) {
@@ -123,6 +127,8 @@ pub fn md4_str(msg: &[u8]) -> ~str {
123127
result
124128
}
125129

130+
/// Calculates the md4 hash of a string, returning the hex-encoded version of
131+
/// the hash
126132
pub fn md4_text(msg: &str) -> ~str { md4_str(str::to_bytes(msg)) }
127133

128134
#[test]

src/libextra/net_ip.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Types/fns concerning Internet Protocol (IP), versions 4 & 6
1212
13+
#[allow(missing_doc)];
14+
1315
use core::prelude::*;
1416

1517
use core::libc;

src/libextra/net_tcp.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
//! High-level interface to libuv's TCP functionality
1212
// FIXME #4425: Need FFI fixes
1313

14+
#[allow(missing_doc)];
15+
1416
use core::prelude::*;
1517

1618
use future;

src/libextra/net_url.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Types/fns concerning URLs (see RFC 3986)
1212
13+
#[allow(missing_doc)];
14+
1315
use core::prelude::*;
1416

1517
use core::cmp::Eq;

src/libextra/num/bigint.rs

+2
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ impl BigUint {
597597
}
598598

599599

600+
/// Converts this big integer into a uint, returning the uint::max_value if
601+
/// it's too large to fit in a uint.
600602
pub fn to_uint(&self) -> uint {
601603
match self.data.len() {
602604
0 => 0,

src/libextra/num/complex.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use core::num::{Zero,One,ToStrRadix};
2525
/// A complex number in Cartesian form.
2626
#[deriving(Eq,Clone)]
2727
pub struct Cmplx<T> {
28+
/// Real portion of the complex number
2829
re: T,
30+
/// Imaginary portion of the complex number
2931
im: T
3032
}
3133

src/libextra/num/rational.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
1211
//! Rational numbers
1312
1413
use core::prelude::*;
@@ -22,6 +21,7 @@ use super::bigint::BigInt;
2221

2322
/// Represents the ratio between 2 numbers.
2423
#[deriving(Clone)]
24+
#[allow(missing_doc)]
2525
pub struct Ratio<T> {
2626
numer: T,
2727
denom: T
@@ -49,7 +49,7 @@ impl<T: Clone + Integer + Ord>
4949
Ratio { numer: numer, denom: denom }
5050
}
5151

52-
// Create a new Ratio. Fails if `denom == 0`.
52+
/// Create a new Ratio. Fails if `denom == 0`.
5353
#[inline(always)]
5454
pub fn new(numer: T, denom: T) -> Ratio<T> {
5555
if denom == Zero::zero() {

src/libextra/priority_queue.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use core::unstable::intrinsics::{move_val_init, init};
1717
use core::util::{replace, swap};
1818
use core::vec;
1919

20+
#[allow(missing_doc)]
2021
pub struct PriorityQueue<T> {
2122
priv data: ~[T],
2223
}

src/libextra/rc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[allow(missing_doc)];
12+
1113
/** Task-local reference counted smart pointers
1214
1315
Task-local reference counted smart pointers are an alternative to managed boxes with deterministic

src/libextra/rope.rs

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
* * access to a character by index is logarithmic (linear in strings);
3434
*/
3535

36+
#[allow(missing_doc)];
37+
3638
use core::prelude::*;
3739

3840
use core::str;

src/libextra/semver.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
//! Semver parsing and logic
1212
13+
#[allow(missing_doc)];
14+
1315
use core::prelude::*;
1416

1517
use core::char;

src/libextra/serialize.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Core encoding and decoding interfaces.
1515
*/
1616

17+
#[allow(missing_doc)];
1718
#[forbid(non_camel_case_types)];
1819

1920
use core::prelude::*;

0 commit comments

Comments
 (0)