Remove macro_use and extern crate in doc tests
diff --git a/src/error.rs b/src/error.rs
index e27a64d..67e3939 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -45,10 +45,9 @@
     /// # Example
     ///
     /// ```
-    /// #[macro_use]
-    /// extern crate syn;
-    ///
-    /// use syn::{Ident, LitStr};
+    /// # extern crate syn;
+    /// #
+    /// use syn::{Ident, LitStr, Token};
     /// use syn::parse::{Error, ParseStream, Result};
     ///
     /// // Parses input that looks like `name = "string"` where the key must be
diff --git a/src/ext.rs b/src/ext.rs
index ae6c2ae..0a412e4 100644
--- a/src/ext.rs
+++ b/src/ext.rs
@@ -18,10 +18,9 @@
     /// identifiers.
     ///
     /// ```rust
-    /// #[macro_use]
-    /// extern crate syn;
-    ///
-    /// use syn::Ident;
+    /// # extern crate syn;
+    /// #
+    /// use syn::{Ident, Token};
     /// use syn::ext::IdentExt;
     /// use syn::parse::{Error, ParseStream, Result};
     ///
diff --git a/src/file.rs b/src/file.rs
index 7cb9f95..1f6054a 100644
--- a/src/file.rs
+++ b/src/file.rs
@@ -19,8 +19,8 @@
     /// representation of the syntax tree.
     ///
     /// ```
-    /// extern crate syn;
-    ///
+    /// # extern crate syn;
+    /// #
     /// use std::env;
     /// use std::fs::File;
     /// use std::io::Read;
diff --git a/src/generics.rs b/src/generics.rs
index af23301..07ea86b 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -303,19 +303,22 @@
     /// ```
     /// # extern crate proc_macro2;
     /// # extern crate syn;
-    /// # #[macro_use]
     /// # extern crate quote;
+    /// #
     /// # use proc_macro2::{Span, Ident};
+    /// # use quote::quote;
+    /// #
     /// # fn main() {
-    /// # let generics: syn::Generics = Default::default();
-    /// # let name = Ident::new("MyType", Span::call_site());
+    /// #     let generics: syn::Generics = Default::default();
+    /// #     let name = Ident::new("MyType", Span::call_site());
+    /// #
     /// let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
     /// quote! {
     ///     impl #impl_generics MyTrait for #name #ty_generics #where_clause {
     ///         // ...
     ///     }
     /// }
-    /// # ;
+    /// #     ;
     /// # }
     /// ```
     ///
diff --git a/src/group.rs b/src/group.rs
index 4b5ba4d..9eb005e 100644
--- a/src/group.rs
+++ b/src/group.rs
@@ -94,11 +94,11 @@
 /// # Example
 ///
 /// ```rust
-/// # #[macro_use]
 /// # extern crate quote;
+/// # extern crate syn;
 /// #
-/// extern crate syn;
-///
+/// # use quote::quote;
+/// #
 /// use syn::{parenthesized, token, Ident, Token, Type};
 /// use syn::parse::{Parse, ParseStream, Result};
 /// use syn::punctuated::Punctuated;
@@ -155,10 +155,10 @@
 ///
 /// ```rust
 /// # extern crate quote;
+/// # extern crate syn;
+/// #
 /// # use quote::quote;
 /// #
-/// extern crate syn;
-///
 /// use syn::{braced, token, Ident, Token, Type};
 /// use syn::parse::{Parse, ParseStream, Result};
 /// use syn::punctuated::Punctuated;
@@ -235,12 +235,12 @@
 /// # Example
 ///
 /// ```rust
-/// # #[macro_use]
+/// # extern crate proc_macro2;
 /// # extern crate quote;
+/// # extern crate syn;
 /// #
-/// extern crate proc_macro2;
-/// extern crate syn;
-///
+/// # use quote::quote;
+/// #
 /// use proc_macro2::TokenStream;
 /// use syn::{bracketed, token, Token};
 /// use syn::parse::{Parse, ParseStream, Result};
diff --git a/src/lib.rs b/src/lib.rs
index 0209fb8..b32d67c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -76,13 +76,12 @@
 //! ```
 //!
 //! ```rust
-//! extern crate proc_macro;
-//! extern crate syn;
-//!
-//! #[macro_use]
-//! extern crate quote;
-//!
+//! # extern crate proc_macro;
+//! # extern crate quote;
+//! # extern crate syn;
+//! #
 //! use proc_macro::TokenStream;
+//! use quote::quote;
 //! use syn::DeriveInput;
 //!
 //! # const IGNORE_TOKENS: &str = stringify! {
@@ -622,14 +621,12 @@
 /// # Examples
 ///
 /// ```rust
-/// extern crate proc_macro;
+/// # extern crate proc_macro;
+/// # extern crate quote;
+/// # extern crate syn;
+/// #
 /// use proc_macro::TokenStream;
-///
-/// extern crate syn;
-///
-/// #[macro_use]
-/// extern crate quote;
-///
+/// use quote::quote;
 /// use syn::DeriveInput;
 ///
 /// # const IGNORE_TOKENS: &str = stringify! {
@@ -688,12 +685,10 @@
 /// # Examples
 ///
 /// ```rust
-/// extern crate syn;
+/// # extern crate syn;
 /// #
-/// #
-/// # type Result<T> = std::result::Result<T, Box<std::error::Error>>;
-///
 /// use syn::Expr;
+/// use syn::parse::Result;
 ///
 /// fn run() -> Result<()> {
 ///     let code = "assert_eq!(u8::max_value(), 255)";
@@ -725,15 +720,13 @@
 /// # Examples
 ///
 /// ```rust,no_run
-/// extern crate syn;
+/// # extern crate syn;
 /// #
-/// #
-/// # type Result<T> = std::result::Result<T, Box<std::error::Error>>;
-///
+/// use std::error::Error;
 /// use std::fs::File;
 /// use std::io::Read;
 ///
-/// fn run() -> Result<()> {
+/// fn run() -> Result<(), Box<Error>> {
 ///     let mut file = File::open("path/to/code.rs")?;
 ///     let mut content = String::new();
 ///     file.read_to_string(&mut content)?;
diff --git a/src/parse.rs b/src/parse.rs
index ae5020a..b98361f 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -78,7 +78,6 @@
 //! [`Parser`]: trait.Parser.html
 //!
 //! ```
-//! # #[macro_use]
 //! # extern crate syn;
 //! #
 //! # extern crate proc_macro2;
@@ -86,7 +85,7 @@
 //! #
 //! use syn::parse::Parser;
 //! use syn::punctuated::Punctuated;
-//! use syn::{PathSegment, Expr, Attribute};
+//! use syn::{Attribute, Expr, PathSegment, Token};
 //!
 //! # fn run_parsers() -> Result<(), syn::parse::Error> {
 //! #     let tokens = TokenStream::new().into();
diff --git a/src/parse_quote.rs b/src/parse_quote.rs
index 62559cb..0cb4565 100644
--- a/src/parse_quote.rs
+++ b/src/parse_quote.rs
@@ -9,13 +9,11 @@
 /// [`Parse`]: parse/trait.Parse.html
 ///
 /// ```
-/// #[macro_use]
-/// extern crate syn;
-///
-/// #[macro_use]
-/// extern crate quote;
-///
-/// use syn::Stmt;
+/// # extern crate syn;
+/// # extern crate quote;
+/// #
+/// use quote::quote;
+/// use syn::{parse_quote, Stmt};
 ///
 /// fn main() {
 ///     let name = quote!(v);
@@ -39,14 +37,14 @@
 /// parameter `T` in the input generics.
 ///
 /// ```
-/// # #[macro_use]
+/// # extern crate quote;
 /// # extern crate syn;
 /// #
-/// # #[macro_use]
-/// # extern crate quote;
+/// # use quote::quote;
+/// # use syn::parse_quote;
 /// #
-/// # use syn::{Generics, GenericParam};
-/// #
+/// use syn::{Generics, GenericParam};
+///
 /// // Add a bound `T: HeapSize` to every type parameter T.
 /// fn add_trait_bounds(mut generics: Generics) -> Generics {
 ///     for param in &mut generics.params {
diff --git a/src/path.rs b/src/path.rs
index e3ae9a7..464c6fb 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -29,13 +29,13 @@
 /// A helper for printing a self-type qualified path as tokens.
 ///
 /// ```rust
-/// extern crate syn;
-/// extern crate quote;
-/// extern crate proc_macro2;
-///
-/// use syn::{QSelf, Path, PathTokens};
+/// # extern crate syn;
+/// # extern crate quote;
+/// # extern crate proc_macro2;
+/// #
 /// use proc_macro2::TokenStream;
 /// use quote::ToTokens;
+/// use syn::{QSelf, Path, PathTokens};
 ///
 /// struct MyNode {
 ///     qself: Option<QSelf>,
diff --git a/src/spanned.rs b/src/spanned.rs
index 80cf6aa..6dd50cb 100644
--- a/src/spanned.rs
+++ b/src/spanned.rs
@@ -29,17 +29,16 @@
 //! static assertion that `Sync` is implemented for that type.
 //!
 //! ```
-//! #[macro_use]
-//! extern crate quote;
-//!
-//! extern crate syn;
-//! extern crate proc_macro;
-//! extern crate proc_macro2;
-//!
-//! use syn::Type;
-//! use syn::spanned::Spanned;
+//! # extern crate proc_macro;
+//! # extern crate proc_macro2;
+//! # extern crate quote;
+//! # extern crate syn;
+//! #
 //! use proc_macro::TokenStream;
 //! use proc_macro2::Span;
+//! use quote::quote_spanned;
+//! use syn::Type;
+//! use syn::spanned::Spanned;
 //!
 //! # const IGNORE_TOKENS: &str = stringify! {
 //! #[proc_macro_derive(MyMacro)]
diff --git a/src/token.rs b/src/token.rs
index 8daa2fe..2e54077 100644
--- a/src/token.rs
+++ b/src/token.rs
@@ -21,10 +21,9 @@
 //! [`ItemStatic`]: ../struct.ItemStatic.html
 //!
 //! ```
-//! # #[macro_use]
 //! # extern crate syn;
 //! #
-//! # use syn::{Attribute, Visibility, Ident, Type, Expr};
+//! # use syn::{Attribute, Expr, Ident, Token, Type, Visibility};
 //! #
 //! pub struct ItemStatic {
 //!     pub attrs: Vec<Attribute>,
@@ -54,38 +53,33 @@
 //! [`braced!`]: ../macro.braced.html
 //!
 //! ```
-//! extern crate syn;
-//!
+//! # extern crate syn;
+//! #
 //! use syn::Attribute;
 //! use syn::parse::{Parse, ParseStream, Result};
 //! #
-//! # struct ItemStatic;
+//! # enum ItemStatic {}
 //!
 //! // Parse the ItemStatic struct shown above.
 //! impl Parse for ItemStatic {
 //!     fn parse(input: ParseStream) -> Result<Self> {
-//! #       Ok(ItemStatic)
-//! #   }
-//! # }
-//! #
-//! # mod example {
-//! #    use super::*;
-//! #    use syn::ItemStatic;
-//! #
-//! #    fn parse(input: ParseStream) -> Result<ItemStatic> {
-//!        Ok(ItemStatic {
-//!            attrs: input.call(Attribute::parse_outer)?,
-//!            vis: input.parse()?,
-//!            static_token: input.parse()?,
-//!            mutability: input.parse()?,
-//!            ident: input.parse()?,
-//!            colon_token: input.parse()?,
-//!            ty: input.parse()?,
-//!            eq_token: input.parse()?,
-//!            expr: input.parse()?,
-//!            semi_token: input.parse()?,
-//!        })
-//!    }
+//!         # use syn::ItemStatic;
+//!         # fn parse(input: ParseStream) -> Result<ItemStatic> {
+//!         Ok(ItemStatic {
+//!             attrs: input.call(Attribute::parse_outer)?,
+//!             vis: input.parse()?,
+//!             static_token: input.parse()?,
+//!             mutability: input.parse()?,
+//!             ident: input.parse()?,
+//!             colon_token: input.parse()?,
+//!             ty: input.parse()?,
+//!             eq_token: input.parse()?,
+//!             expr: input.parse()?,
+//!             semi_token: input.parse()?,
+//!         })
+//!         # }
+//!         # unimplemented!()
+//!     }
 //! }
 //! #
 //! # fn main() {}