From d2b6dd2efc70dd2b7e05fc724463c9d2b3bea273 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 23 Jul 2024 13:20:49 +0200 Subject: [PATCH 1/7] feat(cli): show doc path --- src/compiler.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler.rs b/src/compiler.rs index 46382702..79ef2761 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -200,6 +200,8 @@ impl AmberCompiler { } let filename = dep_path.file_stem().unwrap().to_string_lossy(); let path = format!("{dir_path}/{filename}.md"); + Message::new_err_msg(format!("File generated at `{dir_path}`.")) + .show(); let mut file = File::create(path).unwrap(); file.write_all(document.as_bytes()).unwrap(); } From 62067b5a9b01a57f3552aea23955f6e02bd9121f Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 23 Jul 2024 13:31:32 +0200 Subject: [PATCH 2/7] feat(cli): show doc path --- src/compiler.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 79ef2761..6715070c 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -200,8 +200,8 @@ impl AmberCompiler { } let filename = dep_path.file_stem().unwrap().to_string_lossy(); let path = format!("{dir_path}/{filename}.md"); - Message::new_err_msg(format!("File generated at `{dir_path}`.")) - .show(); + Message::new_err_msg(format!("File generated at `{path}`.")) + .show(); let mut file = File::create(path).unwrap(); file.write_all(document.as_bytes()).unwrap(); } From fb8d48cd3ad40f49c07e861db87dce8925305630 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Tue, 23 Jul 2024 13:32:34 +0200 Subject: [PATCH 3/7] feat(cli): show doc path --- src/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index 6715070c..9b6e3173 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -200,7 +200,7 @@ impl AmberCompiler { } let filename = dep_path.file_stem().unwrap().to_string_lossy(); let path = format!("{dir_path}/{filename}.md"); - Message::new_err_msg(format!("File generated at `{path}`.")) + Message::new_info_msg(format!("File generated at `{path}`.")) .show(); let mut file = File::create(path).unwrap(); file.write_all(document.as_bytes()).unwrap(); From 41b2be687c0dc61f74b3d851cc10c69b45649b8e Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Wed, 24 Jul 2024 11:27:16 +0200 Subject: [PATCH 4/7] feat(help): added parameters --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 7e389be0..298f680e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ struct Cli { #[arg(short, long)] eval: Option, - /// Generate docs + /// Amber-script [output folder (optional)] #[arg(long)] docs: bool } From 23faaf025fbefa29c91841baab8a704b31780d31 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Fri, 26 Jul 2024 11:04:25 +0200 Subject: [PATCH 5/7] Update src/compiler.rs Co-authored-by: Phoenix Himself --- src/compiler.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/compiler.rs b/src/compiler.rs index 9b6e3173..f4ff1088 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -199,12 +199,14 @@ impl AmberCompiler { std::process::exit(1); } let filename = dep_path.file_stem().unwrap().to_string_lossy(); - let path = format!("{dir_path}/{filename}.md"); - Message::new_info_msg(format!("File generated at `{path}`.")) - .show(); - 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, String), Message> { From e3c7fab001b9ed9b0f58772a8bc1d58fd97d29e6 Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Fri, 26 Jul 2024 11:06:02 +0200 Subject: [PATCH 6/7] feat(review): doc --- src/compiler.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index f4ff1088..2b89820e 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -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())); @@ -206,7 +207,7 @@ impl AmberCompiler { } let file_text = if paths.len() > 1 { "Files" } else { "File" }; Message::new_info_msg(format!("{file_text} generated at:\n{}", paths.join("\n"))) - .show(); + .show(); } pub fn compile(&self) -> Result<(Vec, String), Message> { From aa2ad5f65ea42d55b7a9f4eb484887804ca4fcda Mon Sep 17 00:00:00 2001 From: Daniele Scasciafratte Date: Fri, 26 Jul 2024 15:35:16 +0200 Subject: [PATCH 7/7] Update src/main.rs Co-authored-by: Phoenix Himself --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 298f680e..cf89e6b7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,8 @@ struct Cli { #[arg(short, long)] eval: Option, - /// Amber-script [output folder (optional)] + /// Generate docs + /// (OUTPUT is dir instead, default: `docs/`) #[arg(long)] docs: bool }