mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Use xshell::read_file instead of fs::read_to_string
This commit is contained in:
parent
2a20e7795c
commit
aa9be4d523
4 changed files with 10 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
//! Generates `assists.md` documentation.
|
||||
|
||||
use std::{fmt, fs, path::Path};
|
||||
use std::{fmt, path::Path};
|
||||
|
||||
use crate::{
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, reformat, Location, Mode, PREAMBLE},
|
||||
|
@ -39,7 +39,7 @@ impl Assist {
|
|||
return Ok(res);
|
||||
|
||||
fn collect_file(acc: &mut Vec<Assist>, path: &Path) -> Result<()> {
|
||||
let text = fs::read_to_string(path)?;
|
||||
let text = xshell::read_file(path)?;
|
||||
let comment_blocks = extract_comment_blocks_with_empty_lines("Assist", &text);
|
||||
|
||||
for block in comment_blocks {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Generates `assists.md` documentation.
|
||||
|
||||
use std::{fmt, fs, path::PathBuf};
|
||||
use std::{fmt, path::PathBuf};
|
||||
|
||||
use crate::{
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
|
||||
|
@ -8,8 +8,9 @@ use crate::{
|
|||
};
|
||||
|
||||
pub fn generate_diagnostic_docs(mode: Mode) -> Result<()> {
|
||||
let features = Diagnostic::collect()?;
|
||||
let contents = features.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
|
||||
let diagnostics = Diagnostic::collect()?;
|
||||
let contents =
|
||||
diagnostics.into_iter().map(|it| it.to_string()).collect::<Vec<_>>().join("\n\n");
|
||||
let contents = format!("//{}\n{}\n", PREAMBLE, contents.trim());
|
||||
let dst = project_root().join("docs/user/generated_diagnostic.adoc");
|
||||
codegen::update(&dst, &contents, mode)?;
|
||||
|
@ -33,7 +34,7 @@ impl Diagnostic {
|
|||
return Ok(res);
|
||||
|
||||
fn collect_file(acc: &mut Vec<Diagnostic>, path: PathBuf) -> Result<()> {
|
||||
let text = fs::read_to_string(&path)?;
|
||||
let text = xshell::read_file(&path)?;
|
||||
let comment_blocks = extract_comment_blocks_with_empty_lines("Diagnostic", &text);
|
||||
|
||||
for block in comment_blocks {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Generates `assists.md` documentation.
|
||||
|
||||
use std::{fmt, fs, path::PathBuf};
|
||||
use std::{fmt, path::PathBuf};
|
||||
|
||||
use crate::{
|
||||
codegen::{self, extract_comment_blocks_with_empty_lines, Location, Mode, PREAMBLE},
|
||||
|
@ -33,7 +33,7 @@ impl Feature {
|
|||
return Ok(res);
|
||||
|
||||
fn collect_file(acc: &mut Vec<Feature>, path: PathBuf) -> Result<()> {
|
||||
let text = fs::read_to_string(&path)?;
|
||||
let text = xshell::read_file(&path)?;
|
||||
let comment_blocks = extract_comment_blocks_with_empty_lines("Feature", &text);
|
||||
|
||||
for block in comment_blocks {
|
||||
|
|
|
@ -124,7 +124,7 @@ fn existing_tests(dir: &Path, ok: bool) -> Result<HashMap<String, (PathBuf, Test
|
|||
let file_name = path.file_name().unwrap().to_str().unwrap();
|
||||
file_name[5..file_name.len() - 3].to_string()
|
||||
};
|
||||
let text = fs::read_to_string(&path)?;
|
||||
let text = xshell::read_file(&path)?;
|
||||
let test = Test { name: name.clone(), text, ok };
|
||||
if let Some(old) = res.insert(name, (path, test)) {
|
||||
println!("Duplicate test: {:?}", old);
|
||||
|
|
Loading…
Reference in a new issue