aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Aleksanov <[email protected]>2020-10-19 18:58:32 +0100
committerIgor Aleksanov <[email protected]>2020-10-19 18:58:32 +0100
commitaa9be4d5232f27d285211c0c880259655316d114 (patch)
tree340cb5b3a28d57e47314779ab31f367c0ac836ca
parent2a20e7795cc853fd335dcf64b893693514f62bb3 (diff)
Use xshell::read_file instead of fs::read_to_string
-rw-r--r--xtask/src/codegen/gen_assists_docs.rs4
-rw-r--r--xtask/src/codegen/gen_diagnostic_docs.rs9
-rw-r--r--xtask/src/codegen/gen_feature_docs.rs4
-rw-r--r--xtask/src/codegen/gen_parser_tests.rs2
4 files changed, 10 insertions, 9 deletions
diff --git a/xtask/src/codegen/gen_assists_docs.rs b/xtask/src/codegen/gen_assists_docs.rs
index ff307e2aa..d7c85ebe9 100644
--- a/xtask/src/codegen/gen_assists_docs.rs
+++ b/xtask/src/codegen/gen_assists_docs.rs
@@ -1,6 +1,6 @@
1//! Generates `assists.md` documentation. 1//! Generates `assists.md` documentation.
2 2
3use std::{fmt, fs, path::Path}; 3use std::{fmt, path::Path};
4 4
5use crate::{ 5use crate::{
6 codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE}, 6 codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE},
@@ -39,7 +39,7 @@ impl Assist {
39 return Ok(res); 39 return Ok(res);
40 40
41 fn collect_file(acc: &mut Vec<Assist>, path: &Path) -> Result<()> { 41 fn collect_file(acc: &mut Vec<Assist>, path: &Path) -> Result<()> {
42 let text = fs::read_to_string(path)?; 42 let text = xshell::read_file(path)?;
43 let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text); 43 let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text);
44 44
45 for block in comment_blocks { 45 for block in comment_blocks {
diff --git a/xtask/src/codegen/gen_diagnostic_docs.rs b/xtask/src/codegen/gen_diagnostic_docs.rs
index 4d630ce8c..00aaea5b7 100644
--- a/xtask/src/codegen/gen_diagnostic_docs.rs
+++ b/xtask/src/codegen/gen_diagnostic_docs.rs
@@ -1,6 +1,6 @@
1//! Generates `assists.md` documentation. 1//! Generates `assists.md` documentation.
2 2
3use std::{fmt, fs, path::PathBuf}; 3use std::{fmt, path::PathBuf};
4 4
5use crate::{ 5use crate::{
6 codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE}, 6 codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
@@ -8,8 +8,9 @@ use crate::{
8}; 8};
9 9
10pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> { 10pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> {
11 let features = Diagnostic::collect()?; 11 let diagnostics = Diagnostic::collect()?;
12 let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n"); 12 let contents =
13 diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
13 let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim()); 14 let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());
14 let dst = project_root().join("docs/user/generated_diagnostic.adoc"); 15 let dst = project_root().join("docs/user/generated_diagnostic.adoc");
15 codegen::update(&dst, &contents, mode)?; 16 codegen::update(&dst, &contents, mode)?;
@@ -33,7 +34,7 @@ impl Diagnostic {
33 return Ok(res); 34 return Ok(res);
34 35
35 fn collect_file(acc: &mut Vec<Diagnostic>, path: PathBuf) -> Result<()> { 36 fn collect_file(acc: &mut Vec<Diagnostic>, path: PathBuf) -> Result<()> {
36 let text = fs::read_to_string(&path)?; 37 let text = xshell::read_file(&path)?;
37 let comment_blocks = extract_comment_blocks_with_empty_lines("Diagnostic", &text); 38 let comment_blocks = extract_comment_blocks_with_empty_lines("Diagnostic", &text);
38 39
39 for block in comment_blocks { 40 for block in comment_blocks {
diff --git a/xtask/src/codegen/gen_feature_docs.rs b/xtask/src/codegen/gen_feature_docs.rs
index 341e67c73..065dd33f1 100644
--- a/xtask/src/codegen/gen_feature_docs.rs
+++ b/xtask/src/codegen/gen_feature_docs.rs
@@ -1,6 +1,6 @@
1//! Generates `assists.md` documentation. 1//! Generates `assists.md` documentation.
2 2
3use std::{fmt, fs, path::PathBuf}; 3use std::{fmt, path::PathBuf};
4 4
5use crate::{ 5use crate::{
6 codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE}, 6 codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
@@ -33,7 +33,7 @@ impl Feature {
33 return Ok(res); 33 return Ok(res);
34 34
35 fn collect_file(acc: &mut Vec<Feature>, path: PathBuf) -> Result<()> { 35 fn collect_file(acc: &mut Vec<Feature>, path: PathBuf) -> Result<()> {
36 let text = fs::read_to_string(&path)?; 36 let text = xshell::read_file(&path)?;
37 let comment_blocks = extract_comment_blocks_with_empty_lines("Feature", &text); 37 let comment_blocks = extract_comment_blocks_with_empty_lines("Feature", &text);
38 38
39 for block in comment_blocks { 39 for block in comment_blocks {
diff --git a/xtask/src/codegen/gen_parser_tests.rs b/xtask/src/codegen/gen_parser_tests.rs
index 96fdd9216..19ae949d4 100644
--- a/xtask/src/codegen/gen_parser_tests.rs
+++ b/xtask/src/codegen/gen_parser_tests.rs
@@ -124,7 +124,7 @@ fn existing_tests(dir: &Path, ok: bool) -> Result<HashMap<String, (PathBuf, Test
124 let file_name = path.file_name().unwrap().to_str().unwrap(); 124 let file_name = path.file_name().unwrap().to_str().unwrap();
125 file_name[5..file_name.len() - 3].to_string() 125 file_name[5..file_name.len() - 3].to_string()
126 }; 126 };
127 let text = fs::read_to_string(&path)?; 127 let text = xshell::read_file(&path)?;
128 let test = Test { name: name.clone(), text, ok }; 128 let test = Test { name: name.clone(), text, ok };
129 if let Some(old) = res.insert(name, (path, test)) { 129 if let Some(old) = res.insert(name, (path, test)) {
130 println!("Duplicate test: {:?}", old); 130 println!("Duplicate test: {:?}", old);