Skip to content

Commit

Permalink
feat: Add --open to gluon doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwes committed Dec 26, 2018
1 parent 94821a8 commit 89a93c5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ repository = "https://github.com/gluon-lang/gluon"
documentation = "https://docs.rs/gluon"

[dependencies]
log = "0.4"
clap = "2.22.0"
env_logger = "0.6"
walkdir = "1"
failure = { version = "0.1", features = ["backtrace"] }
handlebars = "1.0.0-beta.4"
clap = "2.22.0"
itertools = "0.8"
structopt = "0.2"
lazy_static = "1"
log = "0.4"
opener = "0.3"
pretty = "0.5"
pulldown-cmark = "0.2"
regex = "1"
lazy_static = "1"
structopt = "0.2"
walkdir = "1"

serde = "1.0.0"
serde_derive = "1.0.0"
Expand Down
3 changes: 3 additions & 0 deletions doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,9 @@ const LONG_VERSION: &str = concat!(crate_version!(), "\n", "commit: ", env!("GIT
raw(long_version = "LONG_VERSION")
)]
pub struct Opt {
#[structopt(long = "open")]
#[structopt(help = "Opens the documentation after it has been generated")]
pub open: bool,
#[structopt(help = "Documents the file or directory")]
pub input: String,
#[structopt(help = "Outputs the documentation to this directory")]
Expand Down
13 changes: 12 additions & 1 deletion doc/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
extern crate env_logger;
extern crate failure;
extern crate opener;
extern crate structopt;

extern crate gluon;
extern crate gluon_doc;

use gluon_doc::Opt;
use std::path::Path;

use structopt::StructOpt;

use gluon_doc::Opt;

fn main() {
if let Err(err) = main_() {
eprintln!("{}", err);
Expand All @@ -19,6 +22,14 @@ fn main_() -> Result<(), failure::Error> {
env_logger::init();

let opt = Opt::from_args();

gluon_doc::generate_for_path(&gluon::new_vm(), &opt.input, &opt.output)?;

if opt.open {
let path = Path::new(&opt.output).join(&opt.input).join("index.html");
eprintln!("Opening {}", path.display());
opener::open(path)?;
}

Ok(())
}

0 comments on commit 89a93c5

Please sign in to comment.