Skip to content
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

Show doc path after generated it #338

Merged
merged 7 commits into from
Jul 26, 2024
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
9 changes: 7 additions & 2 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ impl AmberCompiler {
}
let base_dir = base_dir.unwrap();
let ast_forest = self.get_sorted_ast_forest(block, &meta);
let mut paths = vec![];
for (path, block) in ast_forest {
let dep_path = {
let dep_path = fs::canonicalize(PathBuf::from(path.clone()));
Expand Down Expand Up @@ -199,10 +200,14 @@ impl AmberCompiler {
std::process::exit(1);
}
let filename = dep_path.file_stem().unwrap().to_string_lossy();
let path = format!("{dir_path}/{filename}.md");
let mut file = File::create(path).unwrap();
let path = PathBuf::from(dir_path).join(format!("{filename}.md"));
let mut file = File::create(path.clone()).unwrap();
file.write_all(document.as_bytes()).unwrap();
paths.push(String::from(path.to_string_lossy()));
}
let file_text = if paths.len() > 1 { "Files" } else { "File" };
Message::new_info_msg(format!("{file_text} generated at:\n{}", paths.join("\n")))
.show();
}

pub fn compile(&self) -> Result<(Vec<Message>, String), Message> {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct Cli {
eval: Option<String>,

/// Generate docs
/// (OUTPUT is dir instead, default: `docs/`)
#[arg(long)]
docs: bool
}
Expand Down
Loading