Skip to content

Revise graphviz doc-comments to avoid generating files from rustdoc runs. #13976

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
May 8, 2014
Merged
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
51 changes: 39 additions & 12 deletions src/libgraphviz/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@ type Nd = int;
type Ed = (int,int);
struct Edges(Vec<Ed>);

pub fn main() {
use std::io::File;
pub fn render_to<W:Writer>(output: &mut W) {
let edges = Edges(vec!((0,1), (0,2), (1,3), (2,3), (3,4), (4,4)));
let mut f = File::create(&Path::new("example1.dot"));
dot::render(&edges, &mut f).unwrap()
dot::render(&edges, output).unwrap()
}

impl<'a> dot::Labeller<'a, Nd, Ed> for Edges {
Expand Down Expand Up @@ -91,6 +89,17 @@ impl<'a> dot::GraphWalk<'a, Nd, Ed> for Edges {

fn target(&self, e: &Ed) -> Nd { let &(_,t) = e; t }
}

# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
```

```no_run
# pub fn render_to<W:Writer>(output: &mut W) { unimplemented!() }
pub fn main() {
use std::io::File;
let mut f = File::create(&Path::new("example1.dot"));
render_to(&mut f)
}
```

Output from first example (in `example1.dot`):
Expand Down Expand Up @@ -140,19 +149,17 @@ entity `&sube`).
```rust
use dot = graphviz;
use std::str;
use std::io::File;

type Nd = uint;
type Ed<'a> = &'a (uint, uint);
struct Graph { nodes: Vec<&'static str>, edges: Vec<(uint,uint)> }

pub fn main() {
pub fn render_to<W:Writer>(output: &mut W) {
let nodes = vec!("{x,y}","{x}","{y}","{}");
let edges = vec!((0,1), (0,2), (1,3), (2,3));
let graph = Graph { nodes: nodes, edges: edges };

let mut f = File::create(&Path::new("example2.dot"));
dot::render(&graph, &mut f).unwrap()
dot::render(&graph, output).unwrap()
}

impl<'a> dot::Labeller<'a, Nd, Ed<'a>> for Graph {
Expand All @@ -174,6 +181,17 @@ impl<'a> dot::GraphWalk<'a, Nd, Ed<'a>> for Graph {
fn source(&self, e: &Ed) -> Nd { let & &(s,_) = e; s }
fn target(&self, e: &Ed) -> Nd { let & &(_,t) = e; t }
}

# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
```

```no_run
# pub fn render_to<W:Writer>(output: &mut W) { unimplemented!() }
pub fn main() {
use std::io::File;
let mut f = File::create(&Path::new("example2.dot"));
render_to(&mut f)
}
```

The third example is similar to the second, except now each node and
Expand All @@ -187,19 +205,17 @@ Hasse-diagram for the subsets of the set `{x, y}`.
```rust
use dot = graphviz;
use std::str;
use std::io::File;

type Nd<'a> = (uint, &'a str);
type Ed<'a> = (Nd<'a>, Nd<'a>);
struct Graph { nodes: Vec<&'static str>, edges: Vec<(uint,uint)> }

pub fn main() {
pub fn render_to<W:Writer>(output: &mut W) {
let nodes = vec!("{x,y}","{x}","{y}","{}");
let edges = vec!((0,1), (0,2), (1,3), (2,3));
let graph = Graph { nodes: nodes, edges: edges };

let mut f = File::create(&Path::new("example3.dot"));
dot::render(&graph, &mut f).unwrap()
dot::render(&graph, output).unwrap()
}

impl<'a> dot::Labeller<'a, Nd<'a>, Ed<'a>> for Graph {
Expand Down Expand Up @@ -229,6 +245,17 @@ impl<'a> dot::GraphWalk<'a, Nd<'a>, Ed<'a>> for Graph {
fn source(&self, e: &Ed<'a>) -> Nd<'a> { let &(s,_) = e; s }
fn target(&self, e: &Ed<'a>) -> Nd<'a> { let &(_,t) = e; t }
}

# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
```

```no_run
# pub fn render_to<W:Writer>(output: &mut W) { unimplemented!() }
pub fn main() {
use std::io::File;
let mut f = File::create(&Path::new("example3.dot"));
render_to(&mut f)
}
```

# References
Expand Down