Skip to content

rustdoc: Only inject extern crates if not present #12361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/libextra/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ the code for these traits: `#[deriving(Decodable, Encodable)]`
To encode using Encodable :

```rust
extern crate extra;
extern crate serialize;
use extra::json;
use std::io;
Expand Down Expand Up @@ -98,6 +99,7 @@ A basic `ToJson` example using a TreeMap of attribute name / attribute value:


```rust
extern crate extra;
extern crate collections;

use extra::json;
Expand Down Expand Up @@ -128,6 +130,7 @@ fn main() {
To decode a json string using `Decodable` trait :

```rust
extern crate extra;
extern crate serialize;
use serialize::Decodable;

Expand All @@ -154,6 +157,7 @@ Create a struct called TestStruct1 and serialize and deserialize it to and from
using the serialization API, using the derived serialization code.

```rust
extern crate extra;
extern crate serialize;
use extra::json;
use serialize::{Encodable, Decodable};
Expand Down Expand Up @@ -186,6 +190,7 @@ This example use the ToJson impl to unserialize the json string.
Example of `ToJson` trait implementation for TestStruct1.

```rust
extern crate extra;
extern crate serialize;
extern crate collections;

Expand Down
12 changes: 7 additions & 5 deletions src/librustdoc/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ fn maketest(s: &str, cratename: &str) -> ~str {
#[deny(warnings)];
#[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)];
";
if s.contains("extra") {
prog.push_str("extern crate extra;\n");
}
if s.contains(cratename) {
prog.push_str(format!("extern crate {};\n", cratename));
if !s.contains("extern crate") {
if s.contains("extra") {
prog.push_str("extern crate extra;\n");
}
if s.contains(cratename) {
prog.push_str(format!("extern crate {};\n", cratename));
}
}
if s.contains("fn main") {
prog.push_str(s);
Expand Down