about summary refs log tree commit diff
path: root/src/libstd/fmt
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-09-23 17:20:36 -0700
committerAlex Crichton <alex@alexcrichton.com>2013-09-25 14:27:42 -0700
commit3585c64d092082ab2aa16a6d674d063c5d68e1a8 (patch)
tree0474a6b6ae66322964afdef0ddff18c5af3ef73f /src/libstd/fmt
parentdb28c2998015446dd4f3c9615484f0666225aa60 (diff)
downloadrust-3585c64d092082ab2aa16a6d674d063c5d68e1a8.tar.gz
rust-3585c64d092082ab2aa16a6d674d063c5d68e1a8.zip
rustdoc: Change all code-blocks with a script
    find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g'
    find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g'
    find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
Diffstat (limited to 'src/libstd/fmt')
-rw-r--r--src/libstd/fmt/mod.rs60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs
index 99a5ed4d698..f35a61677e8 100644
--- a/src/libstd/fmt/mod.rs
+++ b/src/libstd/fmt/mod.rs
@@ -33,14 +33,14 @@ arguments directly while performing minimal allocations.
 
 Some examples of the `format!` extension are:
 
-~~~{.rust}
+```rust
 format!("Hello")                  // => ~"Hello"
 format!("Hello, {:s}!", "world")  // => ~"Hello, world!"
 format!("The number is {:d}", 1)  // => ~"The number is 1"
 format!("{:?}", ~[3, 4])          // => ~"~[3, 4]"
 format!("{value}", value=4)       // => ~"4"
 format!("{} {}", 1, 2)            // => ~"1 2"
-~~~
+ ```
 
 From these, you can see that the first argument is a format string. It is
 required by the compiler for this to be a string literal; it cannot be a
@@ -67,9 +67,9 @@ function, but the `format!` macro is a syntax extension which allows it to
 leverage named parameters. Named parameters are listed at the end of the
 argument list and have the syntax:
 
-~~~
+ ```
 identifier '=' expression
-~~~
+ ```
 
 It is illegal to put positional parameters (those without names) after arguments
 which have names. Like positional parameters, it is illegal to provided named
@@ -84,9 +84,9 @@ and if all references to one argument do not provide a type, then the format `?`
 is used (the type's rust-representation is printed). For example, this is an
 invalid format string:
 
-~~~
+ ```
 {0:d} {0:s}
-~~~
+ ```
 
 Because the first argument is both referred to as an integer as well as a
 string.
@@ -100,9 +100,9 @@ must have the type `uint`. Although a `uint` can be printed with `{:u}`, it is
 illegal to reference an argument as such. For example, this is another invalid
 format string:
 
-~~~
+ ```
 {:.*s} {0:u}
-~~~
+ ```
 
 ### Formatting traits
 
@@ -134,9 +134,9 @@ is `?` which is defined for all types by default.
 When implementing a format trait for your own time, you will have to implement a
 method of the signature:
 
-~~~{.rust}
+```rust
 fn fmt(value: &T, f: &mut std::fmt::Formatter);
-~~~
+ ```
 
 Your type will be passed by-reference in `value`, and then the function should
 emit output into the `f.buf` stream. It is up to each format trait
@@ -150,14 +150,14 @@ helper methods.
 There are a number of related macros in the `format!` family. The ones that are
 currently implemented are:
 
-~~~{.rust}
+```rust
 format!      // described above
 write!       // first argument is a &mut rt::io::Writer, the destination
 writeln!     // same as write but appends a newline
 print!       // the format string is printed to the standard output
 println!     // same as print but appends a newline
 format_args! // described below.
-~~~
+ ```
 
 
 #### `write!`
@@ -167,12 +167,12 @@ specified stream. This is used to prevent intermediate allocations of format
 strings and instead directly write the output. Under the hood, this function is
 actually invoking the `write` function defined in this module. Example usage is:
 
-~~~{.rust}
+```rust
 use std::rt::io;
 
 let mut w = io::mem::MemWriter::new();
 write!(&mut w as &mut io::Writer, "Hello {}!", "world");
-~~~
+ ```
 
 #### `print!`
 
@@ -180,10 +180,10 @@ This and `println` emit their output to stdout. Similarly to the `write!` macro,
 the goal of these macros is to avoid intermediate allocations when printing
 output. Example usage is:
 
-~~~{.rust}
+```rust
 print!("Hello {}!", "world");
 println!("I have a newline {}", "character at the end");
-~~~
+ ```
 
 #### `format_args!`
 This is a curious macro which is used to safely pass around
@@ -193,13 +193,13 @@ references information on the stack. Under the hood, all of
 the related macros are implemented in terms of this. First
 off, some example usage is:
 
-~~~{.rust}
+```rust
 use std::fmt;
 
 format_args!(fmt::format, "this returns {}", "~str");
 format_args!(|args| { fmt::write(my_writer, args) }, "some {}", "args");
 format_args!(my_fn, "format {}", "string");
-~~~
+ ```
 
 The first argument of the `format_args!` macro is a function (or closure) which
 takes one argument of type `&fmt::Arguments`. This structure can then be
@@ -236,9 +236,9 @@ Furthermore, whenever a case is running, the special character `#` can be used
 to reference the string value of the argument which was selected upon. As an
 example:
 
-~~~{.rust}
+```rust
 format!("{0, select, other{#}}", "hello") // => ~"hello"
-~~~
+ ```
 
 This example is the equivalent of `{0:s}` essentially.
 
@@ -247,9 +247,9 @@ This example is the equivalent of `{0:s}` essentially.
 The select method is a switch over a `&str` parameter, and the parameter *must*
 be of the type `&str`. An example of the syntax is:
 
-~~~
+ ```
 {0, select, male{...} female{...} other{...}}
-~~~
+ ```
 
 Breaking this down, the `0`-th argument is selected upon with the `select`
 method, and then a number of cases follow. Each case is preceded by an
@@ -266,9 +266,9 @@ The plural method is a switch statement over a `uint` parameter, and the
 parameter *must* be a `uint`. A plural method in its full glory can be specified
 as:
 
-~~~
+ ```
 {0, plural, offset=1 =1{...} two{...} many{...} other{...}}
-~~~
+ ```
 
 To break this down, the first `0` indicates that this method is selecting over
 the value of the first positional parameter to the format string. Next, the
@@ -294,7 +294,7 @@ should not be too alien. Arguments are formatted with python-like syntax,
 meaning that arguments are surrounded by `{}` instead of the C-like `%`. The
 actual grammar for the formatting syntax is:
 
-~~~
+ ```
 format_string := <text> [ format <text> ] *
 format := '{' [ argument ] [ ':' format_spec ] [ ',' function_spec ] '}'
 argument := integer | identifier
@@ -315,7 +315,7 @@ plural := 'plural' ',' [ 'offset:' integer ] ( selector arm ) *
 selector := '=' integer | keyword
 keyword := 'zero' | 'one' | 'two' | 'few' | 'many' | 'other'
 arm := '{' format_string '}'
-~~~
+ ```
 
 ## Formatting Parameters
 
@@ -516,11 +516,11 @@ pub trait Float { fn fmt(&Self, &mut Formatter); }
 ///
 /// # Example
 ///
-/// ~~~{.rust}
+/// ```rust
 /// use std::fmt;
 /// let w: &mut io::Writer = ...;
 /// format_args!(|args| { fmt::write(w, args) }, "Hello, {}!", "world");
-/// ~~~
+/// ```
 pub fn write(output: &mut io::Writer, args: &Arguments) {
     unsafe { write_unsafe(output, args.fmt, args.args) }
 }
@@ -581,11 +581,11 @@ pub unsafe fn write_unsafe(output: &mut io::Writer,
 ///
 /// # Example
 ///
-/// ~~~{.rust}
+/// ```rust
 /// use std::fmt;
 /// let s = format_args!(fmt::format, "Hello, {}!", "world");
 /// assert_eq!(s, "Hello, world!");
-/// ~~~
+/// ```
 pub fn format(args: &Arguments) -> ~str {
     unsafe { format_unsafe(args.fmt, args.args) }
 }