aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/lib.rs9
-rw-r--r--xtask/src/main.rs2
-rw-r--r--xtask/tests/tidy-tests/docs.rs15
3 files changed, 18 insertions, 8 deletions
diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs
index cc69463a9..bae4c4650 100644
--- a/xtask/src/lib.rs
+++ b/xtask/src/lib.rs
@@ -3,6 +3,7 @@
3pub mod codegen; 3pub mod codegen;
4 4
5use std::{ 5use std::{
6 env,
6 error::Error, 7 error::Error,
7 fs, 8 fs,
8 io::{Error as IoError, ErrorKind}, 9 io::{Error as IoError, ErrorKind},
@@ -17,7 +18,13 @@ pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
17const TOOLCHAIN: &str = "stable"; 18const TOOLCHAIN: &str = "stable";
18 19
19pub fn project_root() -> PathBuf { 20pub fn project_root() -> PathBuf {
20 Path::new(&env!("CARGO_MANIFEST_DIR")).ancestors().nth(1).unwrap().to_path_buf() 21 Path::new(
22 &env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| env!("CARGO_MANIFEST_DIR").to_owned()),
23 )
24 .ancestors()
25 .nth(1)
26 .unwrap()
27 .to_path_buf()
21} 28}
22 29
23pub struct Cmd<'a> { 30pub struct Cmd<'a> {
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index abcbf7129..e04e45f15 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -2,7 +2,7 @@
2//! 2//!
3//! This binary defines various auxiliary build commands, which are not 3//! This binary defines various auxiliary build commands, which are not
4//! expressible with just `cargo`. Notably, it provides `cargo xtask codegen` 4//! expressible with just `cargo`. Notably, it provides `cargo xtask codegen`
5//! for code genetaiont and `cargo xtask install` for installation of 5//! for code generation and `cargo xtask install` for installation of
6//! rust-analyzer server and client. 6//! rust-analyzer server and client.
7//! 7//!
8//! This binary is integrated into the `cargo` command line by using an alias in 8//! This binary is integrated into the `cargo` command line by using an alias in
diff --git a/xtask/tests/tidy-tests/docs.rs b/xtask/tests/tidy-tests/docs.rs
index 6a629ce63..227937f46 100644
--- a/xtask/tests/tidy-tests/docs.rs
+++ b/xtask/tests/tidy-tests/docs.rs
@@ -36,6 +36,7 @@ fn is_hidden(entry: &DirEntry) -> bool {
36fn no_docs_comments() { 36fn no_docs_comments() {
37 let crates = project_root().join("crates"); 37 let crates = project_root().join("crates");
38 let iter = WalkDir::new(crates); 38 let iter = WalkDir::new(crates);
39 let mut missing_docs = Vec::new();
39 for f in iter.into_iter().filter_entry(|e| !is_hidden(e)) { 40 for f in iter.into_iter().filter_entry(|e| !is_hidden(e)) {
40 let f = f.unwrap(); 41 let f = f.unwrap();
41 if f.file_type().is_dir() { 42 if f.file_type().is_dir() {
@@ -54,12 +55,14 @@ fn no_docs_comments() {
54 let mut line = String::new(); 55 let mut line = String::new();
55 reader.read_line(&mut line).unwrap(); 56 reader.read_line(&mut line).unwrap();
56 if !line.starts_with("//!") { 57 if !line.starts_with("//!") {
57 panic!( 58 missing_docs.push(f.path().display().to_string());
58 "\nMissing docs strings\n\
59 module: {}\n\
60 Need add doc for module\n",
61 f.path().display()
62 )
63 } 59 }
64 } 60 }
61 if !missing_docs.is_empty() {
62 panic!(
63 "\nMissing docs strings\n\n\
64 modules:\n{}\n\n",
65 missing_docs.join("\n")
66 )
67 }
65} 68}