Skip to content

Commit 24784e8

Browse files
committed
auto merge of #6771 : thestinger/rust/highlight, r=luqmana
This works with pandoc linked against highlighting-kate >= 0.5.3.8. It seems to just be a no-op with earlier versions, because I successfully ran this through `try`. This also fixes some consistency issues (like making `Example`/`Examples` always a header and always using three tildes).
2 parents b738b57 + 0d5fdce commit 24784e8

17 files changed

+165
-117
lines changed

src/libextra/arc.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* In this example, a large vector of floats is shared between several tasks.
1818
* With simple pipes, without ARC, a copy would have to be made for each task.
1919
*
20-
* ~~~
20+
* ~~~ {.rust}
2121
* extern mod std;
2222
* use std::arc;
2323
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
@@ -370,7 +370,10 @@ pub impl<T:Const + Owned> RWARC<T> {
370370
* See sync::rwlock.write_downgrade(). The RWWriteMode token must be used
371371
* to obtain the &mut T, and can be transformed into a RWReadMode token by
372372
* calling downgrade(), after which a &T can be obtained instead.
373-
* ~~~
373+
*
374+
* # Example
375+
*
376+
* ~~~ {.rust}
374377
* do arc.write_downgrade |write_mode| {
375378
* do (&write_mode).write_cond |state, condvar| {
376379
* ... exclusive access with mutable state ...

src/libextra/base64.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ impl<'self> ToBase64 for &'self [u8] {
2828
/**
2929
* Turn a vector of `u8` bytes into a base64 string.
3030
*
31-
* *Example*:
31+
* # Example
3232
*
33-
* ~~~~
33+
* ~~~ {.rust}
3434
* extern mod std;
3535
* use std::base64::ToBase64;
3636
*
3737
* fn main () {
3838
* let str = [52,32].to_base64();
3939
* println(fmt!("%s", str));
4040
* }
41-
* ~~~~
41+
* ~~~
4242
*/
4343
fn to_base64(&self) -> ~str {
4444
let mut s = ~"";
@@ -91,17 +91,17 @@ impl<'self> ToBase64 for &'self str {
9191
* Convert any string (literal, `@`, `&`, or `~`) to base64 encoding.
9292
*
9393
*
94-
* *Example*:
94+
* # Example
9595
*
96-
* ~~~~
96+
* ~~~ {.rust}
9797
* extern mod std;
9898
* use std::base64::ToBase64;
9999
*
100100
* fn main () {
101101
* let str = "Hello, World".to_base64();
102102
* println(fmt!("%s",str));
103103
* }
104-
* ~~~~
104+
* ~~~
105105
*
106106
*/
107107
fn to_base64(&self) -> ~str {
@@ -118,9 +118,9 @@ impl FromBase64 for ~[u8] {
118118
* Convert base64 `u8` vector into u8 byte values.
119119
* Every 4 encoded characters is converted into 3 octets, modulo padding.
120120
*
121-
* *Example*:
121+
* # Example
122122
*
123-
* ~~~~
123+
* ~~~ {.rust}
124124
* extern mod std;
125125
* use std::base64::ToBase64;
126126
* use std::base64::FromBase64;
@@ -131,7 +131,7 @@ impl FromBase64 for ~[u8] {
131131
* let bytes = str.from_base64();
132132
* println(fmt!("%?",bytes));
133133
* }
134-
* ~~~~
134+
* ~~~
135135
*/
136136
fn from_base64(&self) -> ~[u8] {
137137
if self.len() % 4u != 0u { fail!("invalid base64 length"); }
@@ -196,11 +196,11 @@ impl FromBase64 for ~str {
196196
* You can use the `from_bytes` function in `core::str`
197197
* to turn a `[u8]` into a string with characters corresponding to those values.
198198
*
199-
* *Example*:
199+
* # Example
200200
*
201201
* This converts a string literal to base64 and back.
202202
*
203-
* ~~~~
203+
* ~~~ {.rust}
204204
* extern mod std;
205205
* use std::base64::ToBase64;
206206
* use std::base64::FromBase64;
@@ -214,7 +214,7 @@ impl FromBase64 for ~str {
214214
* let result_str = str::from_bytes(bytes);
215215
* println(fmt!("%s",result_str));
216216
* }
217-
* ~~~~
217+
* ~~~
218218
*/
219219
fn from_base64(&self) -> ~[u8] {
220220
str::to_bytes(*self).from_base64()

src/libextra/flatpipes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ports and channels.
2525
2626
This example sends boxed integers across tasks using serialization.
2727
28-
~~~
28+
~~~ {.rust}
2929
let (port, chan) = serial::pipe_stream();
3030
3131
do task::spawn || {

src/libextra/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* # Example
1616
*
17-
* ~~~
17+
* ~~~ {.rust}
1818
* # fn fib(n: uint) -> uint {42};
1919
* # fn make_a_sandwich() {};
2020
* let mut delayed_fib = std::future::spawn (|| fib(5000) );

src/libextra/net_tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
466466
* Here, the `new_conn` is used in conjunction with `accept` from within
467467
* a task spawned by the `new_connect_cb` passed into `listen`
468468
*
469-
* ~~~~~~~~~~~
469+
* ~~~ {.rust}
470470
* do net::tcp::listen(remote_ip, remote_port, backlog, iotask,
471471
* // this callback is ran once after the connection is successfully
472472
* // set up
@@ -497,7 +497,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
497497
* None => ()
498498
* }
499499
* };
500-
* ~~~~~~~~~~~
500+
* ~~~
501501
*
502502
* # Arguments
503503
*

src/libextra/sync.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ pub impl RWlock {
545545
* the meantime (such as unlocking and then re-locking as a reader would
546546
* do). The block takes a "write mode token" argument, which can be
547547
* transformed into a "read mode token" by calling downgrade(). Example:
548-
* ~~~
548+
*
549+
* # Example
550+
*
551+
* ~~~ {.rust}
549552
* do lock.write_downgrade |write_mode| {
550553
* do (&write_mode).write_cond |condvar| {
551554
* ... exclusive access ...

src/libstd/bool.rs

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@ use from_str::FromStr;
4343
* Negation of a boolean value.
4444
*
4545
* # Examples
46-
* ~~~
46+
*
47+
* ~~~ {.rust}
4748
* rusti> std::bool::not(true)
4849
* false
4950
* ~~~
51+
*
52+
* ~~~ {.rust}
5053
* rusti> std::bool::not(false)
5154
* true
5255
* ~~~
@@ -57,10 +60,13 @@ pub fn not(v: bool) -> bool { !v }
5760
* Conjunction of two boolean values.
5861
*
5962
* # Examples
60-
* ~~~
63+
*
64+
* ~~~ {.rust}
6165
* rusti> std::bool::and(true, false)
6266
* false
6367
* ~~~
68+
*
69+
* ~~~ {.rust}
6470
* rusti> std::bool::and(true, true)
6571
* true
6672
* ~~~
@@ -71,10 +77,13 @@ pub fn and(a: bool, b: bool) -> bool { a && b }
7177
* Disjunction of two boolean values.
7278
*
7379
* # Examples
74-
* ~~~
80+
*
81+
* ~~~ {.rust}
7582
* rusti> std::bool::or(true, false)
7683
* true
7784
* ~~~
85+
*
86+
* ~~~ {.rust}
7887
* rusti> std::bool::or(false, false)
7988
* false
8089
* ~~~
@@ -87,10 +96,13 @@ pub fn or(a: bool, b: bool) -> bool { a || b }
8796
* 'exclusive or' is identical to `or(and(a, not(b)), and(not(a), b))`.
8897
*
8998
* # Examples
90-
* ~~~
99+
*
100+
* ~~~ {.rust}
91101
* rusti> std::bool::xor(true, false)
92102
* true
93103
* ~~~
104+
*
105+
* ~~~ {.rust}
94106
* rusti> std::bool::xor(true, true)
95107
* false
96108
* ~~~
@@ -105,10 +117,12 @@ pub fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) }
105117
* 'if a then b' is equivalent to `!a || b`.
106118
*
107119
* # Examples
108-
* ~~~
120+
*
121+
* ~~~ {.rust}
109122
* rusti> std::bool::implies(true, true)
110123
* true
111-
* ~~~
124+
*
125+
* ~~~ {.rust}
112126
* rusti> std::bool::implies(true, false)
113127
* false
114128
* ~~~
@@ -121,10 +135,13 @@ pub fn implies(a: bool, b: bool) -> bool { !a || b }
121135
* Two booleans are equal if they have the same value.
122136
*
123137
* # Examples
124-
* ~~~
138+
*
139+
* ~~~ {.rust}
125140
* rusti> std::bool::eq(false, true)
126141
* false
127142
* ~~~
143+
*
144+
* ~~~ {.rust}
128145
* rusti> std::bool::eq(false, false)
129146
* true
130147
* ~~~
@@ -137,10 +154,13 @@ pub fn eq(a: bool, b: bool) -> bool { a == b }
137154
* Two booleans are not equal if they have different values.
138155
*
139156
* # Examples
140-
* ~~~
157+
*
158+
* ~~~ {.rust}
141159
* rusti> std::bool::ne(false, true)
142160
* true
143161
* ~~~
162+
*
163+
* ~~~ {.rust}
144164
* rusti> std::bool::ne(false, false)
145165
* false
146166
* ~~~
@@ -151,10 +171,13 @@ pub fn ne(a: bool, b: bool) -> bool { a != b }
151171
* Is a given boolean value true?
152172
*
153173
* # Examples
154-
* ~~~
174+
*
175+
* ~~~ {.rust}
155176
* rusti> std::bool::is_true(true)
156177
* true
157178
* ~~~
179+
*
180+
* ~~~ {.rust}
158181
* rusti> std::bool::is_true(false)
159182
* false
160183
* ~~~
@@ -165,10 +188,13 @@ pub fn is_true(v: bool) -> bool { v }
165188
* Is a given boolean value false?
166189
*
167190
* # Examples
168-
* ~~~
191+
*
192+
* ~~~ {.rust}
169193
* rusti> std::bool::is_false(false)
170194
* true
171195
* ~~~
196+
*
197+
* ~~~ {.rust}
172198
* rusti> std::bool::is_false(true)
173199
* false
174200
* ~~~
@@ -181,13 +207,18 @@ pub fn is_false(v: bool) -> bool { !v }
181207
* Yields an `Option<bool>`, because `str` may or may not actually be parseable.
182208
*
183209
* # Examples
184-
* ~~~
210+
*
211+
* ~~~ {.rust}
185212
* rusti> FromStr::from_str::<bool>("true")
186213
* Some(true)
187214
* ~~~
215+
*
216+
* ~~~ {.rust}
188217
* rusti> FromStr::from_str::<bool>("false")
189218
* Some(false)
190219
* ~~~
220+
*
221+
* ~~~ {.rust}
191222
* rusti> FromStr::from_str::<bool>("not even a boolean")
192223
* None
193224
* ~~~
@@ -206,10 +237,13 @@ impl FromStr for bool {
206237
* Convert a `bool` to a `str`.
207238
*
208239
* # Examples
209-
* ~~~
240+
*
241+
* ~~~ {.rust}
210242
* rusti> std::bool::to_str(true)
211243
* "true"
212244
* ~~~
245+
*
246+
* ~~~ {.rust}
213247
* rusti> std::bool::to_str(false)
214248
* "false"
215249
* ~~~
@@ -237,10 +271,13 @@ pub fn all_values(blk: &fn(v: bool)) {
237271
* Convert a `bool` to a `u8`.
238272
*
239273
* # Examples
240-
* ~~~
274+
*
275+
* ~~~ {.rust}
241276
* rusti> std::bool::to_bit(true)
242277
* 1
243278
* ~~~
279+
*
280+
* ~~~ {.rust}
244281
* rusti> std::bool::to_bit(false)
245282
* 0
246283
* ~~~

src/libstd/io.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,9 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader {
10091009
/**
10101010
* Gives a `Reader` that allows you to read values from standard input.
10111011
*
1012-
* # Examples
1013-
* ~~~
1012+
* # Example
1013+
*
1014+
* ~~~ {.rust}
10141015
* let stdin = core::io::stdin();
10151016
* let line = stdin.read_line();
10161017
* core::io::print(line);
@@ -1572,8 +1573,9 @@ pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> {
15721573
/**
15731574
* Gives a `Writer` which allows you to write to the standard output.
15741575
*
1575-
* # Examples
1576-
* ~~~
1576+
* # Example
1577+
*
1578+
* ~~~ {.rust}
15771579
* let stdout = core::io::stdout();
15781580
* stdout.write_str("hello\n");
15791581
* ~~~
@@ -1583,8 +1585,9 @@ pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) }
15831585
/**
15841586
* Gives a `Writer` which allows you to write to standard error.
15851587
*
1586-
* # Examples
1587-
* ~~~
1588+
* # Example
1589+
*
1590+
* ~~~ {.rust}
15881591
* let stderr = core::io::stderr();
15891592
* stderr.write_str("hello\n");
15901593
* ~~~
@@ -1597,8 +1600,9 @@ pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) }
15971600
* This string will not have an implicit newline at the end. If you want
15981601
* an implicit newline, please see `println`.
15991602
*
1600-
* # Examples
1601-
* ~~~
1603+
* # Example
1604+
*
1605+
* ~~~ {.rust}
16021606
* // print is imported into the prelude, and so is always available.
16031607
* print("hello");
16041608
* ~~~
@@ -1612,8 +1616,9 @@ pub fn print(s: &str) {
16121616
*
16131617
* If you do not want an implicit newline, please see `print`.
16141618
*
1615-
* # Examples
1616-
* ~~~
1619+
* # Example
1620+
*
1621+
* ~~~ {.rust}
16171622
* // println is imported into the prelude, and so is always available.
16181623
* println("hello");
16191624
* ~~~

0 commit comments

Comments
 (0)