diff options
author | Mikhail Rakhmanov <[email protected]> | 2020-06-03 18:26:01 +0100 |
---|---|---|
committer | Mikhail Rakhmanov <[email protected]> | 2020-06-03 18:26:01 +0100 |
commit | 6a0083a519680e8d16bde5d7c1940c8dd6d4e9d4 (patch) | |
tree | 2b377141d722257cfea18e74b955aea1a8f6cc1a /xtask | |
parent | 1f7de306f547ecb394a34445fd6ac1d6bc8ab439 (diff) | |
parent | 794f6da821c5d6e2490b996baffe162e4753262d (diff) |
Merge branch 'master' into compute-lazy-assits
# Conflicts:
# crates/rust-analyzer/src/main_loop/handlers.rs
# crates/rust-analyzer/src/to_proto.rs
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/codegen.rs | 6 | ||||
-rw-r--r-- | xtask/src/codegen/gen_assists_docs.rs | 11 | ||||
-rw-r--r-- | xtask/src/lib.rs | 2 | ||||
-rw-r--r-- | xtask/src/main.rs | 1 | ||||
-rw-r--r-- | xtask/tests/tidy.rs | 25 |
5 files changed, 21 insertions, 24 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs index 5511c01d5..f5f4b964a 100644 --- a/xtask/src/codegen.rs +++ b/xtask/src/codegen.rs | |||
@@ -18,8 +18,10 @@ use std::{ | |||
18 | use crate::{not_bash::fs2, project_root, Result}; | 18 | use crate::{not_bash::fs2, project_root, Result}; |
19 | 19 | ||
20 | pub use self::{ | 20 | pub use self::{ |
21 | gen_assists_docs::generate_assists_docs, gen_feature_docs::generate_feature_docs, | 21 | gen_assists_docs::{generate_assists_docs, generate_assists_tests}, |
22 | gen_parser_tests::generate_parser_tests, gen_syntax::generate_syntax, | 22 | gen_feature_docs::generate_feature_docs, |
23 | gen_parser_tests::generate_parser_tests, | ||
24 | gen_syntax::generate_syntax, | ||
23 | }; | 25 | }; |
24 | 26 | ||
25 | const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; | 27 | const GRAMMAR_DIR: &str = "crates/ra_parser/src/grammar"; |
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs index 6c1be5350..526941f73 100644 --- a/xtask/src/codegen/gen_assists_docs.rs +++ b/xtask/src/codegen/gen_assists_docs.rs | |||
@@ -7,16 +7,17 @@ use crate::{ | |||
7 | project_root, rust_files, Result, | 7 | project_root, rust_files, Result, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | pub fn generate_assists_docs(mode: Mode) -> Result<()> { | 10 | pub fn generate_assists_tests(mode: Mode) -> Result<()> { |
11 | let assists = Assist::collect()?; | 11 | let assists = Assist::collect()?; |
12 | generate_tests(&assists, mode)?; | 12 | generate_tests(&assists, mode) |
13 | } | ||
13 | 14 | ||
15 | pub fn generate_assists_docs(mode: Mode) -> Result<()> { | ||
16 | let assists = Assist::collect()?; | ||
14 | let contents = assists.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); | 17 | let contents = assists.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); |
15 | let contents = contents.trim().to_string() + "\n"; | 18 | let contents = contents.trim().to_string() + "\n"; |
16 | let dst = project_root().join("docs/user/generated_assists.adoc"); | 19 | let dst = project_root().join("docs/user/generated_assists.adoc"); |
17 | codegen::update(&dst, &contents, mode)?; | 20 | codegen::update(&dst, &contents, mode) |
18 | |||
19 | Ok(()) | ||
20 | } | 21 | } |
21 | 22 | ||
22 | #[derive(Debug)] | 23 | #[derive(Debug)] |
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index 874957885..739f49f7b 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs | |||
@@ -160,6 +160,8 @@ pub fn run_release(dry_run: bool) -> Result<()> { | |||
160 | run!("git reset --hard tags/nightly")?; | 160 | run!("git reset --hard tags/nightly")?; |
161 | run!("git push")?; | 161 | run!("git push")?; |
162 | } | 162 | } |
163 | codegen::generate_assists_docs(Mode::Overwrite)?; | ||
164 | codegen::generate_feature_docs(Mode::Overwrite)?; | ||
163 | 165 | ||
164 | let website_root = project_root().join("../rust-analyzer.github.io"); | 166 | let website_root = project_root().join("../rust-analyzer.github.io"); |
165 | let changelog_dir = website_root.join("./thisweek/_posts"); | 167 | let changelog_dir = website_root.join("./thisweek/_posts"); |
diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 9d7cdd114..81bb3a33f 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs | |||
@@ -74,6 +74,7 @@ FLAGS: | |||
74 | args.finish()?; | 74 | args.finish()?; |
75 | codegen::generate_syntax(Mode::Overwrite)?; | 75 | codegen::generate_syntax(Mode::Overwrite)?; |
76 | codegen::generate_parser_tests(Mode::Overwrite)?; | 76 | codegen::generate_parser_tests(Mode::Overwrite)?; |
77 | codegen::generate_assists_tests(Mode::Overwrite)?; | ||
77 | codegen::generate_assists_docs(Mode::Overwrite)?; | 78 | codegen::generate_assists_docs(Mode::Overwrite)?; |
78 | codegen::generate_feature_docs(Mode::Overwrite)?; | 79 | codegen::generate_feature_docs(Mode::Overwrite)?; |
79 | Ok(()) | 80 | Ok(()) |
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs index 4ac5d929f..d38ac7f17 100644 --- a/xtask/tests/tidy.rs +++ b/xtask/tests/tidy.rs | |||
@@ -25,19 +25,12 @@ fn generated_tests_are_fresh() { | |||
25 | 25 | ||
26 | #[test] | 26 | #[test] |
27 | fn generated_assists_are_fresh() { | 27 | fn generated_assists_are_fresh() { |
28 | if let Err(error) = codegen::generate_assists_docs(Mode::Verify) { | 28 | if let Err(error) = codegen::generate_assists_tests(Mode::Verify) { |
29 | panic!("{}. Please update assists by running `cargo xtask codegen`", error); | 29 | panic!("{}. Please update assists by running `cargo xtask codegen`", error); |
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | #[test] | 33 | #[test] |
34 | fn generated_features_are_fresh() { | ||
35 | if let Err(error) = codegen::generate_feature_docs(Mode::Verify) { | ||
36 | panic!("{}. Please update features by running `cargo xtask codegen`", error); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | #[test] | ||
41 | fn check_code_formatting() { | 34 | fn check_code_formatting() { |
42 | if let Err(error) = run_rustfmt(Mode::Verify) { | 35 | if let Err(error) = run_rustfmt(Mode::Verify) { |
43 | panic!("{}. Please format the code by running `cargo format`", error); | 36 | panic!("{}. Please format the code by running `cargo format`", error); |
@@ -180,13 +173,11 @@ impl TidyDocs { | |||
180 | } | 173 | } |
181 | 174 | ||
182 | fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool { | 175 | fn is_exclude_dir(p: &Path, dirs_to_exclude: &[&str]) -> bool { |
183 | let mut cur_path = p; | 176 | p.strip_prefix(project_root()) |
184 | while let Some(path) = cur_path.parent() { | 177 | .unwrap() |
185 | if dirs_to_exclude.iter().any(|dir| path.ends_with(dir)) { | 178 | .components() |
186 | return true; | 179 | .rev() |
187 | } | 180 | .skip(1) |
188 | cur_path = path; | 181 | .filter_map(|it| it.as_os_str().to_str()) |
189 | } | 182 | .any(|it| dirs_to_exclude.contains(&it)) |
190 | |||
191 | false | ||
192 | } | 183 | } |