-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "docgen" | ||
version = "0.1.0" | ||
authors = ["Ticki <Ticki@users.noreply.github.com>"] | ||
|
||
[dependencies] | ||
walkdir = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#![feature(unicode)] | ||
|
||
extern crate walkdir; | ||
extern crate rustc_unicode; | ||
|
||
use walkdir::WalkDir; | ||
use std::fs::File; | ||
use std::io::prelude::*; | ||
|
||
fn main() { | ||
for entry in WalkDir::new(".").follow_links(true).into_iter().map(|x| x.expect("Couldn't walk dir.")).filter(|x| x.file_type().is_file()) { | ||
let mut string = String::new(); | ||
|
||
File::open(entry.path()).expect("Could't open file.") | ||
.read_to_string(&mut string) | ||
.expect("Could't read file."); | ||
|
||
for i in string.split("@MANSTART{").skip(1) { | ||
let end_delimiter = i.find('}').expect("Unclosed '{'"); | ||
let name = &i[..end_delimiter]; | ||
assert!(name.lines().count() == 1, "malformed manpage name"); | ||
|
||
let mut man_page = &i[end_delimiter + 1..i.find("@MANEND") | ||
.expect("Unclosed @MANSTART (use @MANEND).")].trim(); | ||
|
||
let mut string = String::with_capacity(man_page.len() + man_page.len() / 3); | ||
|
||
for i in man_page.lines() { | ||
string.push_str(i.trim_left_matches('\\') | ||
.trim_left_matches("// ") | ||
.trim_left_matches("//! ") | ||
.trim_left_matches("/// ") | ||
.trim_left_matches("->") | ||
.trim_left_matches("<!-")); | ||
string.push('\n') | ||
} | ||
|
||
let mut file = File::create("man/".to_owned() + name).expect("Couldn't create man page."); | ||
file.write(&string.as_bytes()[1..string.len() - 1]).expect("Couldn't write man page."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test doc mode | ||
myltiline | ||
Oh, snap. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ere you go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eah test 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@MANSTART{test1} | ||
here you go | ||
@MANEND | ||
|
||
@MANSTART{test2} | ||
yeah test 2 | ||
@MANEND | ||
|
||
/// <!- @MANSTART{doc} -> | ||
/// test doc mode | ||
/// <!- @MANEND -> | ||
|
||
/// <!- @MANSTART{doc-ml} -> | ||
/// test doc mode | ||
/// myltiline | ||
/// Oh, snap. | ||
/// <!- @MANEND -> |