Skip to content

Commit b22556a

Browse files
committed
core: Convert to rustdoc
1 parent a052197 commit b22556a

32 files changed

+1075
-2114
lines changed

src/libcore/bool.rs

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,36 @@ export from_str, to_str, all_values, to_bit;
1010
#[doc = "The type of boolean logic values"]
1111
type t = bool;
1212

13-
#[doc(
14-
brief = "Negation/Inverse"
15-
)]
13+
#[doc = "Negation/Inverse"]
1614
pure fn not(v: t) -> t { !v }
1715

18-
#[doc(
19-
brief = "Conjunction"
20-
)]
16+
#[doc = "Conjunction"]
2117
pure fn and(a: t, b: t) -> t { a && b }
2218

23-
#[doc(
24-
brief = "Disjunction"
25-
)]
19+
#[doc = "Disjunction"]
2620
pure fn or(a: t, b: t) -> t { a || b }
2721

28-
#[doc(
29-
brief = "Exclusive or, i.e. `or(and(a, not(b)), and(not(a), b))`"
30-
)]
22+
#[doc = "Exclusive or, i.e. `or(and(a, not(b)), and(not(a), b))`"]
3123
pure fn xor(a: t, b: t) -> t { (a && !b) || (!a && b) }
3224

33-
#[doc(
34-
brief = "Implication in the logic, i.e. from `a` follows `b`"
35-
)]
25+
#[doc = "Implication in the logic, i.e. from `a` follows `b`"]
3626
pure fn implies(a: t, b: t) -> t { !a || b }
3727

38-
#[doc(
39-
brief = "true if truth values `a` and `b` \
40-
are indistinguishable in the logic"
41-
)]
28+
#[doc = "
29+
true if truth values `a` and `b` are indistinguishable in the logic
30+
"]
4231
pure fn eq(a: t, b: t) -> bool { a == b }
4332

44-
#[doc(
45-
brief = "true if truth values `a` and `b` are distinguishable in the logic"
46-
)]
33+
#[doc = "true if truth values `a` and `b` are distinguishable in the logic"]
4734
pure fn ne(a: t, b: t) -> bool { a != b }
4835

49-
#[doc(
50-
brief = "true if `v` represents truth in the logic"
51-
)]
36+
#[doc = "true if `v` represents truth in the logic"]
5237
pure fn is_true(v: t) -> bool { v }
5338

54-
#[doc(
55-
brief = "true if `v` represents falsehood in the logic"
56-
)]
39+
#[doc = "true if `v` represents falsehood in the logic"]
5740
pure fn is_false(v: t) -> bool { !v }
5841

59-
#[doc(
60-
brief = "Parse logic value from `s`"
61-
)]
42+
#[doc = "Parse logic value from `s`"]
6243
pure fn from_str(s: str) -> option<t> {
6344
alt check s {
6445
"true" { some(true) }
@@ -67,23 +48,19 @@ pure fn from_str(s: str) -> option<t> {
6748
}
6849
}
6950

70-
#[doc(
71-
brief = "Convert `v` into a string"
72-
)]
51+
#[doc = "Convert `v` into a string"]
7352
pure fn to_str(v: t) -> str { if v { "true" } else { "false" } }
7453

75-
#[doc(
76-
brief = "Iterates over all truth values by passing them to `blk` \
77-
in an unspecified order"
78-
)]
54+
#[doc = "
55+
Iterates over all truth values by passing them to `blk` in an unspecified
56+
order
57+
"]
7958
fn all_values(blk: fn(v: t)) {
8059
blk(true);
8160
blk(false);
8261
}
8362

84-
#[doc(
85-
brief = "converts truth value to an 8 bit byte"
86-
)]
63+
#[doc = "converts truth value to an 8 bit byte"]
8764
pure fn to_bit(v: t) -> u8 { if v { 1u8 } else { 0u8 } }
8865

8966
#[test]

src/libcore/box.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
#[doc = "Operations on shared box types"];
2+
13
export ptr_eq;
24

3-
#[doc(
4-
brief = "Determine if two shared boxes point to the same object"
5-
)]
65
pure fn ptr_eq<T>(a: @T, b: @T) -> bool unchecked {
6+
#[doc = "Determine if two shared boxes point to the same object"];
77
ptr::addr_of(*a) == ptr::addr_of(*b)
88
}
99

src/libcore/char.rs

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,66 +45,72 @@ import is_XID_start = unicode::derived_property::XID_Start;
4545
import is_XID_continue = unicode::derived_property::XID_Continue;
4646

4747

48-
#[doc(
49-
brief = "Indicates whether a character is in lower case, defined \
50-
in terms of the Unicode General Category 'Ll'."
51-
)]
48+
#[doc = "
49+
Indicates whether a character is in lower case, defined
50+
in terms of the Unicode General Category 'Ll'
51+
"]
5252
pure fn is_lowercase(c: char) -> bool {
5353
ret unicode::general_category::Ll(c);
5454
}
5555

56-
#[doc(
57-
brief = "Indicates whether a character is in upper case, defined \
58-
in terms of the Unicode General Category 'Lu'."
59-
)]
56+
#[doc = "
57+
Indicates whether a character is in upper case, defined
58+
in terms of the Unicode General Category 'Lu'.
59+
"]
6060
pure fn is_uppercase(c: char) -> bool {
6161
ret unicode::general_category::Lu(c);
6262
}
6363

64-
#[doc(
65-
brief = "Indicates whether a character is whitespace, defined in \
66-
terms of the Unicode General Categories 'Zs', 'Zl', 'Zp' \
67-
additional 'Cc'-category control codes in the range [0x09, 0x0d]"
68-
)]
64+
#[doc = "
65+
Indicates whether a character is whitespace, defined in
66+
terms of the Unicode General Categories 'Zs', 'Zl', 'Zp'
67+
additional 'Cc'-category control codes in the range [0x09, 0x0d]
68+
"]
6969
pure fn is_whitespace(c: char) -> bool {
7070
ret ('\x09' <= c && c <= '\x0d')
7171
|| unicode::general_category::Zs(c)
7272
|| unicode::general_category::Zl(c)
7373
|| unicode::general_category::Zp(c);
7474
}
7575

76-
#[doc(
77-
brief = "Indicates whether a character is alphanumeric, defined \
78-
in terms of the Unicode General Categories 'Nd', \
79-
'Nl', 'No' and the Derived Core Property 'Alphabetic'."
80-
)]
76+
#[doc = "
77+
Indicates whether a character is alphanumeric, defined
78+
in terms of the Unicode General Categories 'Nd',
79+
'Nl', 'No' and the Derived Core Property 'Alphabetic'.
80+
"]
8181
pure fn is_alphanumeric(c: char) -> bool {
8282
ret unicode::derived_property::Alphabetic(c) ||
8383
unicode::general_category::Nd(c) ||
8484
unicode::general_category::Nl(c) ||
8585
unicode::general_category::No(c);
8686
}
8787

88-
#[doc( brief = "Indicates whether the character is an ASCII character" )]
88+
#[doc = "Indicates whether the character is an ASCII character"]
8989
pure fn is_ascii(c: char) -> bool {
9090
c - ('\x7F' & c) == '\x00'
9191
}
9292

93-
#[doc( brief = "Indicates whether the character is numeric (Nd, Nl, or No)" )]
93+
#[doc = "Indicates whether the character is numeric (Nd, Nl, or No)"]
9494
pure fn is_digit(c: char) -> bool {
9595
ret unicode::general_category::Nd(c) ||
9696
unicode::general_category::Nl(c) ||
9797
unicode::general_category::No(c);
9898
}
9999

100-
#[doc(
101-
brief = "Convert a char to the corresponding digit. \
102-
Safety note: This function fails if `c` is not a valid char",
103-
return = "If `c` is between '0' and '9', the corresponding value \
104-
between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is \
105-
'b' or 'B', 11, etc. Returns none if the char does not \
106-
refer to a digit in the given radix."
107-
)]
100+
#[doc = "
101+
Convert a char to the corresponding digit.
102+
103+
# Safety note
104+
105+
This function fails if `c` is not a valid char
106+
107+
# Return value
108+
109+
If `c` is between '0' and '9', the corresponding value
110+
between 0 and 9. If `c` is 'a' or 'A', 10. If `c` is
111+
'b' or 'B', 11, etc. Returns none if the char does not
112+
refer to a digit in the given radix.
113+
"]
108114
pure fn to_digit(c: char, radix: uint) -> option<uint> {
109115
let val = alt c {
110116
'0' to '9' { c as uint - ('0' as uint) }
@@ -119,9 +125,7 @@ pure fn to_digit(c: char, radix: uint) -> option<uint> {
119125
/*
120126
FIXME: works only on ASCII
121127
*/
122-
#[doc(
123-
brief = "Convert a char to the corresponding lower case."
124-
)]
128+
#[doc = "Convert a char to the corresponding lower case."]
125129
pure fn to_lower(c: char) -> char {
126130
alt c {
127131
'A' to 'Z' { ((c as u8) + 32u8) as char }
@@ -132,20 +136,21 @@ pure fn to_lower(c: char) -> char {
132136
/*
133137
FIXME: works only on ASCII
134138
*/
135-
#[doc(
136-
brief = "Convert a char to the corresponding upper case."
137-
)]
139+
#[doc = "Convert a char to the corresponding upper case."]
138140
pure fn to_upper(c: char) -> char {
139141
alt c {
140142
'a' to 'z' { ((c as u8) - 32u8) as char }
141143
_ { c }
142144
}
143145
}
144146

145-
#[doc(
146-
brief = "Compare two chars.",
147-
return = "-1 if a<b, 0 if a==b, +1 if a>b"
148-
)]
147+
#[doc = "
148+
Compare two chars
149+
150+
# Return value
151+
152+
-1 if a < b, 0 if a == b, +1 if a > b
153+
"]
149154
pure fn cmp(a: char, b: char) -> int {
150155
ret if b > a { -1 }
151156
else if b < a { 1 }

src/libcore/comm.rs

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#[doc(
2-
brief = "Communication between tasks",
3-
desc = "
1+
#[doc = "
2+
Communication between tasks
43
54
Communication between tasks is facilitated by ports (in the receiving
65
task), and channels (in the sending task). Any number of channels may
@@ -11,15 +10,19 @@ vectors, strings, and records, tags, tuples and unique boxes (`~T`)
1110
thereof. Most notably, shared boxes (`@T`) may not be transmitted
1211
across channels.
1312
14-
Example:
13+
# Example
1514
16-
let p = comm::port();
17-
task::spawn(comm::chan(p), fn (c: chan<str>) {
18-
comm::send(c, \"Hello, World\");
19-
});
20-
io::println(comm::recv(p));
15+
~~~
16+
let po = comm::port();
17+
let ch = comm::chan(po);
2118
22-
")];
19+
task::spawn {||
20+
comm::send(ch, \"Hello, World\");
21+
});
22+
23+
io::println(comm::recv(p));
24+
~~~
25+
"];
2326

2427
import sys;
2528
import task;
@@ -65,18 +68,16 @@ type port_id = int;
6568

6669
// It's critical that this only have one variant, so it has a record
6770
// layout, and will work in the rust_task structure in task.rs.
68-
#[doc(
69-
brief = "A communication endpoint that can send messages. \
70-
Channels send messages to ports.",
71-
desc = "Each channel is bound to a port when the channel is \
72-
constructed, so the destination port for a channel \
73-
must exist before the channel itself. \
74-
Channels are weak: a channel does not keep the port it \
75-
is bound to alive. If a channel attempts to send data \
76-
to a dead port that data will be silently dropped. \
77-
Channels may be duplicated and themselves transmitted \
78-
over other channels."
79-
)]
71+
#[doc = "
72+
A communication endpoint that can send messages
73+
74+
Each channel is bound to a port when the channel is constructed, so
75+
the destination port for a channel must exist before the channel
76+
itself. Channels are weak: a channel does not keep the port it is
77+
bound to alive. If a channel attempts to send data to a dead port that
78+
data will be silently dropped. Channels may be duplicated and
79+
themselves transmitted over other channels.
80+
"]
8081
enum chan<T: send> {
8182
chan_t(task_id, port_id)
8283
}
@@ -104,21 +105,19 @@ resource port_ptr<T: send>(po: *rust_port) {
104105
rustrt::del_port(po);
105106
}
106107

107-
#[doc(
108-
brief = "A communication endpoint that can receive messages. \
109-
Ports receive messages from channels.",
110-
desc = "Each port has a unique per-task identity and may not \
111-
be replicated or transmitted. If a port value is \
112-
copied, both copies refer to the same port. \
113-
Ports may be associated with multiple <chan>s."
114-
)]
108+
#[doc = "
109+
A communication endpoint that can receive messages
110+
111+
Each port has a unique per-task identity and may not be replicated or
112+
transmitted. If a port value is copied, both copies refer to the same
113+
port. Ports may be associated with multiple `chan`s.
114+
"]
115115
enum port<T: send> { port_t(@port_ptr<T>) }
116116

117-
#[doc(
118-
brief = "Sends data over a channel. The sent data is moved \
119-
into the channel, whereupon the caller loses \
120-
access to it."
121-
)]
117+
#[doc = "
118+
Sends data over a channel. The sent data is moved into the channel,
119+
whereupon the caller loses access to it.
120+
"]
122121
fn send<T: send>(ch: chan<T>, -data: T) {
123122
let chan_t(t, p) = ch;
124123
let res = rustrt::chan_id_send(sys::get_type_desc::<T>(), t, p, data);
@@ -129,23 +128,18 @@ fn send<T: send>(ch: chan<T>, -data: T) {
129128
task::yield();
130129
}
131130

132-
#[doc(
133-
brief = "Constructs a port."
134-
)]
131+
#[doc = "Constructs a port"]
135132
fn port<T: send>() -> port<T> {
136133
port_t(@port_ptr(rustrt::new_port(sys::size_of::<T>())))
137134
}
138135

139-
#[doc(
140-
brief = "Receive from a port. \
141-
If no data is available on the port then the task will \
142-
block until data becomes available."
143-
)]
136+
#[doc = "
137+
Receive from a port. If no data is available on the port then the
138+
task will block until data becomes available.
139+
"]
144140
fn recv<T: send>(p: port<T>) -> T { recv_(***p) }
145141

146-
#[doc(
147-
brief = "Receive on a raw port pointer"
148-
)]
142+
#[doc = "Receive on a raw port pointer"]
149143
fn recv_<T: send>(p: *rust_port) -> T {
150144
// FIXME: Due to issue 1185 we can't use a return pointer when
151145
// calling C code, and since we can't create our own return
@@ -218,10 +212,10 @@ fn peek<T: send>(p: port<T>) -> bool {
218212
rustrt::rust_port_size(***p) != 0u as ctypes::size_t
219213
}
220214

221-
#[doc(
222-
brief = "Constructs a channel. The channel is bound to the \
223-
port used to construct it."
224-
)]
215+
#[doc = "
216+
Constructs a channel. The channel is bound to the port used to
217+
construct it.
218+
"]
225219
fn chan<T: send>(p: port<T>) -> chan<T> {
226220
chan_t(rustrt::get_task_id(), rustrt::get_port_id(***p))
227221
}

0 commit comments

Comments
 (0)