From 5d7614197d44448ba70791eaefd90fe2f45db762 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jan 2020 18:03:24 +0100 Subject: :arrow_up: rust --- xtask/src/install.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xtask') diff --git a/xtask/src/install.rs b/xtask/src/install.rs index bffd91af1..8c65b51e3 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs @@ -7,7 +7,7 @@ use anyhow::{Context, Result}; use crate::cmd::{run, run_with_output, Cmd}; // Latest stable, feel free to send a PR if this lags behind. -const REQUIRED_RUST_VERSION: u32 = 40; +const REQUIRED_RUST_VERSION: u32 = 41; pub struct InstallCmd { pub client: Option, -- cgit v1.2.3 From 755077e3720bd97e1e506bf8fbe0a2534389f282 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 6 Feb 2020 18:10:25 +0100 Subject: Doctest autoimport --- xtask/src/codegen/gen_assists_docs.rs | 42 +++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 69f9b4872..697e830df 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs @@ -20,6 +20,28 @@ struct Assist { after: String, } +fn hide_hash_comments(text: &str) -> String { + text.split('\n') // want final newline + .filter(|&it| !(it.starts_with("# ") || it == "#")) + .map(|it| format!("{}\n", it)) + .collect() +} + +fn reveal_hash_comments(text: &str) -> String { + text.split('\n') // want final newline + .map(|it| { + if it.starts_with("# ") { + &it[2..] + } else if it == "#" { + "" + } else { + it + } + }) + .map(|it| format!("{}\n", it)) + .collect() +} + fn collect_assists() -> Result> { let mut res = Vec::new(); for entry in fs::read_dir(project_root().join(codegen::ASSISTS_DIR))? { @@ -91,13 +113,14 @@ fn doctest_{}() {{ check( "{}", r#####" -{} -"#####, r#####" -{} -"#####) +{}"#####, r#####" +{}"#####) }} "######, - assist.id, assist.id, assist.before, assist.after + assist.id, + assist.id, + reveal_hash_comments(&assist.before), + reveal_hash_comments(&assist.after) ); buf.push_str(&test) @@ -123,12 +146,13 @@ fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> { ```rust // BEFORE {} - // AFTER -{} -``` +{}``` ", - assist.id, assist.doc, before, after + assist.id, + assist.doc, + hide_hash_comments(&before), + hide_hash_comments(&after) ); buf.push_str(&docs); } -- cgit v1.2.3 From 561b4b11ff1d87ea1ff2477dcba6ae1f396573a3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 7 Feb 2020 15:53:31 +0100 Subject: Name assist handlers --- xtask/src/codegen.rs | 2 +- xtask/tests/tidy-tests/docs.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'xtask') diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index efa638e06..a53d57335 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs @@ -25,7 +25,7 @@ const ERR_INLINE_TESTS_DIR: &str = "crates/ra_syntax/test_data/parser/inline/err pub const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs"; pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs"; -const ASSISTS_DIR: &str = "crates/ra_assists/src/assists"; +const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; const ASSISTS_DOCS: &str = "docs/user/assists.md"; diff --git a/xtask/tests/tidy-tests/docs.rs b/xtask/tests/tidy-tests/docs.rs index 8a005d6c4..6a69e7d6a 100644 --- a/xtask/tests/tidy-tests/docs.rs +++ b/xtask/tests/tidy-tests/docs.rs @@ -6,7 +6,7 @@ use xtask::project_root; fn is_exclude_dir(p: &Path) -> bool { // Test hopefully don't really need comments, and for assists we already // have special comments which are source of doc tests and user docs. - let exclude_dirs = ["tests", "test_data", "assists"]; + let exclude_dirs = ["tests", "test_data", "handlers"]; let mut cur_path = p; while let Some(path) = cur_path.parent() { if exclude_dirs.iter().any(|dir| path.ends_with(dir)) { -- cgit v1.2.3 From 740a26b7d26a68cc46becda3cca39091e8da67fc Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 7 Feb 2020 23:35:34 +0200 Subject: Rename add import assist --- xtask/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'xtask') diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 9b0afe8e0..8fdf43e4a 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -53,8 +53,7 @@ fn reformat(text: impl std::fmt::Display) -> Result { write!(rustfmt.stdin.take().unwrap(), "{}", text)?; let output = rustfmt.wait_with_output()?; let stdout = String::from_utf8(output.stdout)?; - // TODO: update the preable: replace ra_tools with the relevant path - let preamble = "Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`"; + let preamble = "Generated file, do not edit by hand, see `xtask/src/codegen`"; Ok(format!("//! {}\n\n{}", preamble, stdout)) } -- cgit v1.2.3