]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #12298 : alexcrichton/rust/rustdoc-testing, r=sfackler
authorbors <bors@rust-lang.org>
Sun, 16 Feb 2014 00:36:27 +0000 (16:36 -0800)
committerbors <bors@rust-lang.org>
Sun, 16 Feb 2014 00:36:27 +0000 (16:36 -0800)
It's too easy to forget the `rust` tag to test something.

Closes #11698

21 files changed:
src/doc/rustdoc.md
src/libextra/json.rs
src/libextra/stats.rs
src/libglob/lib.rs
src/librustdoc/html/markdown.rs
src/librustdoc/test.rs
src/libstd/comm/mod.rs
src/libstd/fmt/mod.rs
src/libstd/io/comm_adapters.rs
src/libstd/io/net/unix.rs
src/libstd/kinds.rs
src/libstd/logging.rs
src/libstd/num/int_macros.rs
src/libstd/num/mod.rs
src/libstd/rand/distributions/gamma.rs
src/libstd/str.rs
src/libstd/task.rs
src/libstd/unstable/finally.rs
src/libstd/vec.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/generic.rs

index 83d1275ab970f00df1964bd12aaf0407cd445733..3809dcd3f48ade0325e9e1f80a88591a5b577b45 100644 (file)
@@ -100,34 +100,29 @@ rustdoc --test crate.rs
 
 ## Defining tests
 
-Rust documentation currently uses the markdown format, and code blocks can refer
-to any piece of code-related documentation, which isn't always rust. Because of
-this, only code blocks with the language of "rust" will be considered for
-testing.
+Rust documentation currently uses the markdown format, and rustdoc treats all
+code blocks as testable-by-default. In order to not run a test over a block of
+code, the `ignore` string can be added to the three-backtick form of markdown
+code block.
 
 ~~~
-```rust
+```
 // This is a testable code block
 ```
 
-```
+```ignore
 // This is not a testable code block
 ```
 
-    // This is not a testable code block (4-space indent)
+    // This is a testable code block (4-space indent)
 ~~~
 
-In addition to only testing "rust"-language code blocks, there are additional
-specifiers that can be used to dictate how a code block is tested:
+In addition to the `ignore` directive, you can specify that the test's execution
+should fail with the `should_fail` directive.
 
 ~~~
-```rust,ignore
-// This code block is ignored by rustdoc, but is passed through to the test
-// harness
-```
-
-```rust,should_fail
-// This code block is expected to generate a failure
+```should_fail
+// This code block is expected to generate a failure when run
 ```
 ~~~
 
@@ -143,7 +138,7 @@ that one can still write things like `#[deriving(Eq)]`).
 # the doc-generating tool.  In order to display them anyway in this particular
 # case, the character following the leading '#' is not a usual space like in
 # these first five lines but a non breakable one.
-# 
+#
 # // showing 'fib' in this documentation would just be tedious and detracts from
 # // what's actualy being documented.
 # fn fib(n: int) { n + 2 }
@@ -169,9 +164,6 @@ rustdoc --test lib.rs --test-args 'foo'
 
 // See what's possible when running tests
 rustdoc --test lib.rs --test-args '--help'
-
-// Run all ignored tests
-rustdoc --test lib.rs --test-args '--ignored'
 ~~~
 
 When testing a library, code examples will often show how functions are used,
index a0ca9eca1bda862b8ef39414670cf227e088c864..4c6cd4218e7ae9b49fd12da9749dbb0bf2e0c52b 100644 (file)
@@ -30,7 +30,7 @@
 Arrays are enclosed in square brackets ([ ... ]) and objects in curly brackets ({ ... }).
 A simple JSON document encoding a person, his/her age, address and phone numbers could look like:
 
-```
+```ignore
 {
     "FirstName": "John",
     "LastName": "Doe",
index 174f5fcfc030fda250403cbb7f2f77f6c9328e7f..799157f9a1a7842054f5bc4b94f344707d5c870e 100644 (file)
@@ -341,7 +341,7 @@ pub fn write_5_number_summary(w: &mut io::Writer,
 /// As an example, the summary with 5-number-summary `(min=15, q1=17, med=20, q3=24, max=31)` might
 /// display as:
 ///
-/// ~~~~
+/// ~~~~ignore
 ///   10 |        [--****#******----------]          | 40
 /// ~~~~
 
index cb6f5b24a0943eb562601091e139fff20dcf67be..3a93b10ad29c825756441f182c0d79c54cb8b2f5 100644 (file)
@@ -67,7 +67,7 @@ pub struct Paths {
 ///
 /// The above code will print:
 ///
-/// ```
+/// ```ignore
 /// /media/pictures/kittens.jpg
 /// /media/pictures/puppies.jpg
 /// ```
index 7c9448bb73241a6c34166c128bf0db81fce2d842..3668d4d3a2cbaef6a3ce91edbd3398e59abcb050 100644 (file)
@@ -172,21 +172,23 @@ pub fn render(w: &mut io::Writer, s: &str) -> fmt::Result {
 pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
     extern fn block(_ob: *buf, text: *buf, lang: *buf, opaque: *libc::c_void) {
         unsafe {
-            if text.is_null() || lang.is_null() { return }
-            let (test, shouldfail, ignore) =
+            if text.is_null() { return }
+            let (shouldfail, ignore) = if lang.is_null() {
+                (false, false)
+            } else {
                 vec::raw::buf_as_slice((*lang).data,
                                        (*lang).size as uint, |lang| {
                     let s = str::from_utf8(lang).unwrap();
-                    (s.contains("rust"), s.contains("should_fail"),
-                     s.contains("ignore"))
-                });
-            if !test { return }
+                    (s.contains("should_fail"), s.contains("ignore"))
+                })
+            };
+            if ignore { return }
             vec::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
                 let tests: &mut ::test::Collector = intrinsics::transmute(opaque);
                 let text = str::from_utf8(text).unwrap();
                 let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l));
                 let text = lines.to_owned_vec().connect("\n");
-                tests.add_test(text, ignore, shouldfail);
+                tests.add_test(text, shouldfail);
             })
         }
     }
index 4b32cdb77eabd406f2b9e7efb3eff2d652b79990..8b127b6079d9075f18110f41238e780dc3a3fc6d 100644 (file)
@@ -94,7 +94,7 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
     0
 }
 
-fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
+fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool) {
     let test = maketest(test, cratename);
     let parsesess = parse::new_parse_sess();
     let input = driver::StrInput(test);
@@ -130,9 +130,10 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>) {
     match out {
         Err(e) => fail!("couldn't run the test: {}", e),
         Ok(out) => {
-            if !out.status.success() {
-                fail!("test executable failed:\n{}",
-                      str::from_utf8(out.error));
+            if should_fail && out.status.success() {
+                fail!("test executable succeeded when it should have failed");
+            } else if !should_fail && !out.status.success() {
+                fail!("test executable failed:\n{}", str::from_utf8(out.error));
             }
         }
     }
@@ -169,7 +170,7 @@ pub struct Collector {
 }
 
 impl Collector {
-    pub fn add_test(&mut self, test: &str, ignore: bool, should_fail: bool) {
+    pub fn add_test(&mut self, test: &str, should_fail: bool) {
         let test = test.to_owned();
         let name = format!("{}_{}", self.names.connect("::"), self.cnt);
         self.cnt += 1;
@@ -180,11 +181,11 @@ pub fn add_test(&mut self, test: &str, ignore: bool, should_fail: bool) {
         self.tests.push(test::TestDescAndFn {
             desc: test::TestDesc {
                 name: test::DynTestName(name),
-                ignore: ignore,
-                should_fail: should_fail,
+                ignore: false,
+                should_fail: false, // compiler failures are test failures
             },
             testfn: test::DynTestFn(proc() {
-                runtest(test, cratename, libs);
+                runtest(test, cratename, libs, should_fail);
             }),
         });
     }
index 3487a92d8491cfa25c3274ba8a35d1716a328de1..6fc0cb71c5c9b0ebded79e9c02c5bd2247b0c797 100644 (file)
@@ -61,7 +61,7 @@
 //! let (port, chan) = Chan::new();
 //! spawn(proc() {
 //!     chan.send(10);
-//! })
+//! });
 //! assert_eq!(port.recv(), 10);
 //!
 //! // Create a shared channel which can be sent along from many tasks
index cfcb467d7aa64e63967bc42728c9e7f2c462894a..bbf3b3292bf199ef2960c1369bf31f0315f019f1 100644 (file)
@@ -82,7 +82,7 @@
 leverage named parameters. Named parameters are listed at the end of the
 argument list and have the syntax:
 
-```
+```ignore
 identifier '=' expression
 ```
 
 is used (the type's rust-representation is printed). For example, this is an
 invalid format string:
 
-```
+```ignore
 {0:d} {0:s}
 ```
 
 illegal to reference an argument as such. For example, this is another invalid
 format string:
 
-```
+```ignore
 {:.*s} {0:u}
 ```
 
@@ -334,7 +334,7 @@ fn main() {
 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:
 
-```
+```ignore
 {0, select, male{...} female{...} other{...}}
 ```
 
@@ -353,7 +353,7 @@ fn main() {
 parameter *must* be a `uint`. A plural method in its full glory can be specified
 as:
 
-```
+```ignore
 {0, plural, offset=1 =1{...} two{...} many{...} other{...}}
 ```
 
@@ -381,7 +381,7 @@ fn main() {
 meaning that arguments are surrounded by `{}` instead of the C-like `%`. The
 actual grammar for the formatting syntax is:
 
-```
+```ignore
 format_string := <text> [ format <text> ] *
 format := '{' [ argument ] [ ':' format_spec ] [ ',' function_spec ] '}'
 argument := integer | identifier
index bf2c6dbb623f354c270e4a3c32c5b851e260fbae..10e1f88690332a04845711b0344804d33c0f9b81 100644 (file)
 /// # Example
 ///
 /// ```
-/// let reader = PortReader::new(port);
+/// use std::io::PortReader;
+///
+/// let (port, chan) = Chan::new();
+/// # drop(chan);
+/// let mut reader = PortReader::new(port);
 ///
 /// let mut buf = ~[0u8, ..100];
 /// match reader.read(buf) {
-///     Some(nread) => println!("Read {} bytes", nread),
-///     None => println!("At the end of the stream!")
+///     Ok(nread) => println!("Read {} bytes", nread),
+///     Err(e) => println!("read error: {}", e),
 /// }
 /// ```
 pub struct PortReader {
@@ -83,7 +87,12 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 /// # Example
 ///
 /// ```
-/// let writer = ChanWriter::new(chan);
+/// # #[allow(unused_must_use)];
+/// use std::io::ChanWriter;
+///
+/// let (port, chan) = Chan::new();
+/// # drop(port);
+/// let mut writer = ChanWriter::new(chan);
 /// writer.write("hello, world".as_bytes());
 /// ```
 pub struct ChanWriter {
index 6ce4a6fdc875815ecfeaf5870c2190075f5d868f..23c01aa635444d4675789c0e1b9e72730ed3e0f2 100644 (file)
@@ -91,15 +91,18 @@ impl UnixListener {
     /// # Example
     ///
     /// ```
+    /// # fn main() {}
+    /// # fn foo() {
+    /// # #[allow(unused_must_use)];
     /// use std::io::net::unix::UnixListener;
-    /// use std::io::Listener;
+    /// use std::io::{Listener, Acceptor};
     ///
-    /// let server = Path::new("path/to/my/socket");
-    /// let mut stream = UnixListener::bind(&server);
-    /// for client in stream.incoming() {
-    ///     let mut client = client;
+    /// let server = Path::new("/path/to/my/socket");
+    /// let stream = UnixListener::bind(&server);
+    /// for mut client in stream.listen().incoming() {
     ///     client.write([1, 2, 3, 4]);
     /// }
+    /// # }
     /// ```
     pub fn bind<P: ToCStr>(path: &P) -> IoResult<UnixListener> {
         LocalIo::maybe_raise(|io| {
index 51e9e9b386474e04e99288241257b85bc517cc5d..61b24f67f66dff3d7dce586e4e41d05185c5c5a8 100644 (file)
@@ -69,7 +69,9 @@ pub mod marker {
     /// Given a struct `S` that includes a type parameter `T`
     /// but does not actually *reference* that type parameter:
     ///
-    /// ```
+    /// ```ignore
+    /// use std::cast;
+    ///
     /// struct S<T> { x: *() }
     /// fn get<T>(s: &S<T>) -> T {
     ///    unsafe {
@@ -109,6 +111,8 @@ pub mod marker {
     /// but does not actually *reference* that type parameter:
     ///
     /// ```
+    /// use std::cast;
+    ///
     /// struct S<T> { x: *() }
     /// fn get<T>(s: &S<T>, v: T) {
     ///    unsafe {
@@ -147,7 +151,8 @@ pub mod marker {
     /// "interior" mutability:
     ///
     /// ```
-    /// struct Cell<T> { priv value: T }
+    /// pub struct Cell<T> { priv value: T }
+    /// # fn main() {}
     /// ```
     ///
     /// The type system would infer that `value` is only read here and
index 165a83aa975cd639c149b3fa4c6480f611c8d164..9aa63f15def3100e2a113e69d76cbba149dd3518 100644 (file)
@@ -42,7 +42,7 @@
 `RUST_LOG` environment variable. The value of this environment variable is a
 comma-separated list of logging directives. A logging directive is of the form:
 
-```
+```ignore
 path::to::module=log_level
 ```
 
@@ -65,7 +65,7 @@
 
 Some examples of valid values of `RUST_LOG` are:
 
-```
+```ignore
 hello                // turns on all logging for the 'hello' module
 info                 // turns on all info logging
 hello=debug          // turns on debug logging for 'hello'
index 4965d0606115d43012a6ee42811b688a0374ac2d..fe3c18d1c4f542d224ae8bc3f6e78fff1dc11424 100644 (file)
@@ -119,6 +119,8 @@ impl Rem<$T,$T> for $T {
     /// Returns the integer remainder after division, satisfying:
     ///
     /// ```
+    /// # let n = 1;
+    /// # let d = 2;
     /// assert!((n / d) * d + (n % d) == n)
     /// ```
     ///
@@ -194,15 +196,15 @@ impl Integer for $T {
     /// # Examples
     ///
     /// ```
-    /// assert!(( 8).div_floor( 3) ==  2);
-    /// assert!(( 8).div_floor(-3) == -3);
-    /// assert!((-8).div_floor( 3) == -3);
-    /// assert!((-8).div_floor(-3) ==  2);
-    ///
-    /// assert!(( 1).div_floor( 2) ==  0);
-    /// assert!(( 1).div_floor(-2) == -1);
-    /// assert!((-1).div_floor( 2) == -1);
-    /// assert!((-1).div_floor(-2) ==  0);
+    /// assert!(( 8i).div_floor(& 3) ==  2);
+    /// assert!(( 8i).div_floor(&-3) == -3);
+    /// assert!((-8i).div_floor(& 3) == -3);
+    /// assert!((-8i).div_floor(&-3) ==  2);
+    ///
+    /// assert!(( 1i).div_floor(& 2) ==  0);
+    /// assert!(( 1i).div_floor(&-2) == -1);
+    /// assert!((-1i).div_floor(& 2) == -1);
+    /// assert!((-1i).div_floor(&-2) ==  0);
     /// ```
     ///
     #[inline]
@@ -220,21 +222,22 @@ fn div_floor(&self, other: &$T) -> $T {
     /// Integer modulo, satisfying:
     ///
     /// ```
-    /// assert!(n.div_floor(d) * d + n.mod_floor(d) == n)
+    /// # let n = 1i; let d = 1i;
+    /// assert!(n.div_floor(&d) * d + n.mod_floor(&d) == n)
     /// ```
     ///
     /// # Examples
     ///
     /// ```
-    /// assert!(( 8).mod_floor( 3) ==  2);
-    /// assert!(( 8).mod_floor(-3) == -1);
-    /// assert!((-8).mod_floor( 3) ==  1);
-    /// assert!((-8).mod_floor(-3) == -2);
-    ///
-    /// assert!(( 1).mod_floor( 2) ==  1);
-    /// assert!(( 1).mod_floor(-2) == -1);
-    /// assert!((-1).mod_floor( 2) ==  1);
-    /// assert!((-1).mod_floor(-2) == -1);
+    /// assert!(( 8i).mod_floor(& 3) ==  2);
+    /// assert!(( 8i).mod_floor(&-3) == -1);
+    /// assert!((-8i).mod_floor(& 3) ==  1);
+    /// assert!((-8i).mod_floor(&-3) == -2);
+    ///
+    /// assert!(( 1i).mod_floor(& 2) ==  1);
+    /// assert!(( 1i).mod_floor(&-2) == -1);
+    /// assert!((-1i).mod_floor(& 2) ==  1);
+    /// assert!((-1i).mod_floor(&-2) == -1);
     /// ```
     ///
     #[inline]
index c9908dde6e0645e8b3ec6034e1b8981398c6ba60..493069139ef2b9d434e31f3335d810b2ba45fe33 100644 (file)
@@ -45,7 +45,7 @@ pub trait Zero: Add<Self, Self> {
     ///
     /// # Laws
     ///
-    /// ~~~
+    /// ~~~ignore
     /// a + 0 = a       ∀ a ∈ Self
     /// 0 + a = a       ∀ a ∈ Self
     /// ~~~
@@ -71,7 +71,7 @@ pub trait One: Mul<Self, Self> {
     ///
     /// # Laws
     ///
-    /// ~~~
+    /// ~~~ignore
     /// a * 1 = a       ∀ a ∈ Self
     /// 1 * a = a       ∀ a ∈ Self
     /// ~~~
@@ -964,6 +964,8 @@ impl FromPrimitive for $T {
 /// # Example
 ///
 /// ```
+/// use std::num;
+///
 /// let twenty: f32 = num::cast(0x14).unwrap();
 /// assert_eq!(twenty, 20f32);
 /// ```
index 2f1890b02333c4088f67fa14e340bb79f14af4fd..0915d49945dc5a00835f33cf4463e710c9fd90a2 100644 (file)
@@ -20,7 +20,7 @@
 ///
 /// The density function of this distribution is
 ///
-/// ```
+/// ```ignore
 /// f(x) =  x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k)
 /// ```
 ///
index 063182ff0e1d9fa1e7dfc69735a9d69720a40cb1..023900e5d41158b9964e4f482143a6b63360bd7a 100644 (file)
@@ -2011,7 +2011,7 @@ pub trait StrSlice<'a> {
     ///
     /// ## Output
     ///
-    /// ```
+    /// ```ignore
     /// 0: 中
     /// 3: 华
     /// 6: V
index 1cdf5998e8b203cfe1bf983d1b12ef6e41110e09..1065d3b39419b78413f8fda731f086ddb70aaf4e 100644 (file)
@@ -46,7 +46,7 @@
  *
  * ```
  * spawn(proc() {
- *     log(error, "Hello, World!");
+ *     println!("Hello, World!");
  * })
  * ```
  */
index 433accecdbcfdbff270ee337aa383265ee08403a..6fb8981b681c3c1dfbcbb60ef98b821425afd332 100644 (file)
 
 # Example
 
- ```
+```
+use std::unstable::finally::Finally;
+# fn always_run_this() {}
+
 (|| {
-    ...
+    // ...
 }).finally(|| {
     always_run_this();
 })
- ```
+```
 */
 
 use ops::Drop;
@@ -69,13 +72,16 @@ fn finally(&self, dtor: ||) -> T {
  * # Example
  *
  * ```
+ * use std::unstable::finally::try_finally;
+ *
  * struct State<'a> { buffer: &'a mut [u8], len: uint }
+ * # let mut buf = [];
  * let mut state = State { buffer: buf, len: 0 };
  * try_finally(
  *     &mut state, (),
  *     |state, ()| {
  *         // use state.buffer, state.len
- *     }
+ *     },
  *     |state| {
  *         // use state.buffer, state.len to cleanup
  *     })
index 9d0cc6022afdc9224b3b2d7ffc9d5781afc09ba2..9d9ebad1c69b2934b4ce7b1ef24d740b6f107ea0 100644 (file)
@@ -955,7 +955,7 @@ pub trait ImmutableVector<'a, T> {
      *
      * Equivalent to:
      *
-     * ```
+     * ```ignore
      *     if self.len() == 0 { return None }
      *     let head = &self[0];
      *     *self = self.slice_from(1);
@@ -973,7 +973,7 @@ pub trait ImmutableVector<'a, T> {
      *
      * Equivalent to:
      *
-     * ```
+     * ```ignore
      *     if self.len() == 0 { return None; }
      *     let tail = &self[self.len() - 1];
      *     *self = self.slice_to(self.len() - 1);
@@ -2075,7 +2075,7 @@ pub trait MutableVector<'a, T> {
      *
      * Equivalent to:
      *
-     * ```
+     * ```ignore
      *     if self.len() == 0 { return None; }
      *     let head = &mut self[0];
      *     *self = self.mut_slice_from(1);
@@ -2093,7 +2093,7 @@ pub trait MutableVector<'a, T> {
      *
      * Equivalent to:
      *
-     * ```
+     * ```ignore
      *     if self.len() == 0 { return None; }
      *     let tail = &mut self[self.len() - 1];
      *     *self = self.mut_slice_to(self.len() - 1);
index 468cb1544a25de7c36617c7c744df080f2c8a16d..9e0439e5375c9834d60692c6b8209f0307530ca8 100644 (file)
 
 For example, a type like:
 
+```ignore
     #[deriving(Encodable, Decodable)]
     struct Node {id: uint}
+```
 
 would generate two implementations like:
 
@@ -43,11 +45,14 @@ fn decode(d: &D) -> Node {
 Other interesting scenarios are whe the item has type parameters or
 references other non-built-in types.  A type definition like:
 
+```ignore
     #[deriving(Encodable, Decodable)]
     struct spanned<T> {node: T, span: Span}
+```
 
 would yield functions like:
 
+```ignore
     impl<
         S: Encoder,
         T: Encodable<S>
@@ -73,6 +78,7 @@ fn decode(d: &D) -> spanned<T> {
             })
         }
     }
+```
 */
 
 use ast::{MetaItem, Item, Expr, MutMutable};
index 3db07b05e527db69f81a5c5d11e2cfb10c15bb64..029e87afbe21223fafe958b32c8035e0f2a64a36 100644 (file)
@@ -59,7 +59,7 @@
 an identifier in the source code. For example, the `x`s in the
 following snippet
 
-~~~
+~~~ignore
 struct A { x : int }
 
 struct B(int);
@@ -83,7 +83,7 @@ enum C {
 
 The following simplified `Eq` is used for in-code examples:
 
-~~~
+~~~ignore
 trait Eq {
     fn eq(&self, other: &Self);
 }
@@ -101,7 +101,7 @@ fn eq(&self, other: &int) -> bool {
 
 When generating the `expr` for the `A` impl, the `SubstructureFields` is
 
-~~~
+~~~ignore
 Struct(~[FieldInfo {
            span: <span of x>
            name: Some(<ident of x>),
@@ -112,7 +112,7 @@ fn eq(&self, other: &int) -> bool {
 
 For the `B` impl, called with `B(a)` and `B(b)`,
 
-~~~
+~~~ignore
 Struct(~[FieldInfo {
           span: <span of `int`>,
           name: None,
@@ -126,7 +126,7 @@ fn eq(&self, other: &int) -> bool {
 When generating the `expr` for a call with `self == C0(a)` and `other
 == C0(b)`, the SubstructureFields is
 
-~~~
+~~~ignore
 EnumMatching(0, <ast::Variant for C0>,
              ~[FieldInfo {
                 span: <span of int>
@@ -138,7 +138,7 @@ fn eq(&self, other: &int) -> bool {
 
 For `C1 {x}` and `C1 {x}`,
 
-~~~
+~~~ignore
 EnumMatching(1, <ast::Variant for C1>,
              ~[FieldInfo {
                 span: <span of x>
@@ -150,7 +150,7 @@ fn eq(&self, other: &int) -> bool {
 
 For `C0(a)` and `C1 {x}` ,
 
-~~~
+~~~ignore
 EnumNonMatching(~[(0, <ast::Variant for B0>,
                    ~[(<span of int>, None, <expr for &a>)]),
                   (1, <ast::Variant for B1>,
@@ -164,7 +164,7 @@ fn eq(&self, other: &int) -> bool {
 
 A static method on the above would result in,
 
-~~~~
+~~~~ignore
 StaticStruct(<ast::StructDef of A>, Named(~[(<ident of x>, <span of x>)]))
 
 StaticStruct(<ast::StructDef of B>, Unnamed(~[<span of x>]))
@@ -346,7 +346,9 @@ pub fn expand(&self,
      * Given that we are deriving a trait `Tr` for a type `T<'a, ...,
      * 'z, A, ..., Z>`, creates an impl like:
      *
+     * ```ignore
      *      impl<'a, ..., 'z, A:Tr B1 B2, ..., Z: Tr B1 B2> Tr for T<A, ..., Z> { ... }
+     * ```
      *
      * where B1, B2, ... are the bounds given by `bounds_paths`.'
      *
@@ -620,7 +622,7 @@ fn create_method(&self,
     }
 
     /**
-   ~~~
+   ~~~ignore
     #[deriving(Eq)]
     struct A { x: int, y: int }
 
@@ -719,7 +721,7 @@ fn expand_static_struct_method_body(&self,
     }
 
     /**
-   ~~~
+   ~~~ignore
     #[deriving(Eq)]
     enum A {
         A1
@@ -762,7 +764,7 @@ fn expand_enum_method_body(&self,
     /**
     Creates the nested matches for an enum definition recursively, i.e.
 
-   ~~~
+   ~~~ignore
     match self {
        Variant1 => match other { Variant1 => matching, Variant2 => nonmatching, ... },
        Variant2 => match other { Variant1 => nonmatching, Variant2 => matching, ... },
@@ -1166,7 +1168,7 @@ pub fn cs_fold(use_foldl: bool,
 Call the method that is being derived on all the fields, and then
 process the collected results. i.e.
 
-~~~
+~~~ignore
 f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
               self_2.method(__arg_1_2, __arg_2_2)])
 ~~~