diff options
author | Kevin DeLorey <[email protected]> | 2020-02-09 16:25:47 +0000 |
---|---|---|
committer | Kevin DeLorey <[email protected]> | 2020-02-09 16:37:43 +0000 |
commit | a957c473fdb79880c39b73dc9e0c923093cf16ac (patch) | |
tree | f998b548f530ce604651e0e6af314ed2ec74b3b5 /xtask | |
parent | 22caf982b99c54058e2e9200aeea0e61cada284a (diff) | |
parent | 1b9b13b4b4a75b5531c3f046ce6bf72d681f2732 (diff) |
Merge branch 'master' into kdelorey/complete-trait-impl
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/codegen.rs | 2 | ||||
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 42 | ||||
-rw-r--r-- | xtask/src/install.rs | 2 | ||||
-rw-r--r-- | xtask/src/lib.rs | 3 | ||||
-rw-r--r-- | xtask/tests/tidy-tests/docs.rs | 2 |
5 files changed, 37 insertions, 14 deletions
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 | |||
25 | pub const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs"; | 25 | pub const SYNTAX_KINDS: &str = "crates/ra_parser/src/syntax_kind/generated.rs"; |
26 | pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs"; | 26 | pub const AST: &str = "crates/ra_syntax/src/ast/generated.rs"; |
27 | 27 | ||
28 | const ASSISTS_DIR: &str = "crates/ra_assists/src/assists"; | 28 | const ASSISTS_DIR: &str = "crates/ra_assists/src/handlers"; |
29 | const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; | 29 | const ASSISTS_TESTS: &str = "crates/ra_assists/src/doc_tests/generated.rs"; |
30 | const ASSISTS_DOCS: &str = "docs/user/assists.md"; | 30 | const ASSISTS_DOCS: &str = "docs/user/assists.md"; |
31 | 31 | ||
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 { | |||
20 | after: String, | 20 | after: String, |
21 | } | 21 | } |
22 | 22 | ||
23 | fn hide_hash_comments(text: &str) -> String { | ||
24 | text.split('\n') // want final newline | ||
25 | .filter(|&it| !(it.starts_with("# ") || it == "#")) | ||
26 | .map(|it| format!("{}\n", it)) | ||
27 | .collect() | ||
28 | } | ||
29 | |||
30 | fn reveal_hash_comments(text: &str) -> String { | ||
31 | text.split('\n') // want final newline | ||
32 | .map(|it| { | ||
33 | if it.starts_with("# ") { | ||
34 | &it[2..] | ||
35 | } else if it == "#" { | ||
36 | "" | ||
37 | } else { | ||
38 | it | ||
39 | } | ||
40 | }) | ||
41 | .map(|it| format!("{}\n", it)) | ||
42 | .collect() | ||
43 | } | ||
44 | |||
23 | fn collect_assists() -> Result<Vec<Assist>> { | 45 | fn collect_assists() -> Result<Vec<Assist>> { |
24 | let mut res = Vec::new(); | 46 | let mut res = Vec::new(); |
25 | for entry in fs::read_dir(project_root().join(codegen::ASSISTS_DIR))? { | 47 | for entry in fs::read_dir(project_root().join(codegen::ASSISTS_DIR))? { |
@@ -91,13 +113,14 @@ fn doctest_{}() {{ | |||
91 | check( | 113 | check( |
92 | "{}", | 114 | "{}", |
93 | r#####" | 115 | r#####" |
94 | {} | 116 | {}"#####, r#####" |
95 | "#####, r#####" | 117 | {}"#####) |
96 | {} | ||
97 | "#####) | ||
98 | }} | 118 | }} |
99 | "######, | 119 | "######, |
100 | assist.id, assist.id, assist.before, assist.after | 120 | assist.id, |
121 | assist.id, | ||
122 | reveal_hash_comments(&assist.before), | ||
123 | reveal_hash_comments(&assist.after) | ||
101 | ); | 124 | ); |
102 | 125 | ||
103 | buf.push_str(&test) | 126 | buf.push_str(&test) |
@@ -123,12 +146,13 @@ fn generate_docs(assists: &[Assist], mode: Mode) -> Result<()> { | |||
123 | ```rust | 146 | ```rust |
124 | // BEFORE | 147 | // BEFORE |
125 | {} | 148 | {} |
126 | |||
127 | // AFTER | 149 | // AFTER |
128 | {} | 150 | {}``` |
129 | ``` | ||
130 | ", | 151 | ", |
131 | assist.id, assist.doc, before, after | 152 | assist.id, |
153 | assist.doc, | ||
154 | hide_hash_comments(&before), | ||
155 | hide_hash_comments(&after) | ||
132 | ); | 156 | ); |
133 | buf.push_str(&docs); | 157 | buf.push_str(&docs); |
134 | } | 158 | } |
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}; | |||
7 | use crate::cmd::{run, run_with_output, Cmd}; | 7 | use crate::cmd::{run, run_with_output, Cmd}; |
8 | 8 | ||
9 | // Latest stable, feel free to send a PR if this lags behind. | 9 | // Latest stable, feel free to send a PR if this lags behind. |
10 | const REQUIRED_RUST_VERSION: u32 = 40; | 10 | const REQUIRED_RUST_VERSION: u32 = 41; |
11 | 11 | ||
12 | pub struct InstallCmd { | 12 | pub struct InstallCmd { |
13 | pub client: Option<ClientOpt>, | 13 | pub client: Option<ClientOpt>, |
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<String> { | |||
53 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; | 53 | write!(rustfmt.stdin.take().unwrap(), "{}", text)?; |
54 | let output = rustfmt.wait_with_output()?; | 54 | let output = rustfmt.wait_with_output()?; |
55 | let stdout = String::from_utf8(output.stdout)?; | 55 | let stdout = String::from_utf8(output.stdout)?; |
56 | // TODO: update the preable: replace ra_tools with the relevant path | 56 | let preamble = "Generated file, do not edit by hand, see `xtask/src/codegen`"; |
57 | let preamble = "Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`"; | ||
58 | Ok(format!("//! {}\n\n{}", preamble, stdout)) | 57 | Ok(format!("//! {}\n\n{}", preamble, stdout)) |
59 | } | 58 | } |
60 | 59 | ||
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; | |||
6 | fn is_exclude_dir(p: &Path) -> bool { | 6 | fn is_exclude_dir(p: &Path) -> bool { |
7 | // Test hopefully don't really need comments, and for assists we already | 7 | // Test hopefully don't really need comments, and for assists we already |
8 | // have special comments which are source of doc tests and user docs. | 8 | // have special comments which are source of doc tests and user docs. |
9 | let exclude_dirs = ["tests", "test_data", "assists"]; | 9 | let exclude_dirs = ["tests", "test_data", "handlers"]; |
10 | let mut cur_path = p; | 10 | let mut cur_path = p; |
11 | while let Some(path) = cur_path.parent() { | 11 | while let Some(path) = cur_path.parent() { |
12 | if exclude_dirs.iter().any(|dir| path.ends_with(dir)) { | 12 | if exclude_dirs.iter().any(|dir| path.ends_with(dir)) { |