aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_tools/tests/docs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_tools/tests/docs.rs')
-rw-r--r--crates/ra_tools/tests/docs.rs63
1 files changed, 0 insertions, 63 deletions
diff --git a/crates/ra_tools/tests/docs.rs b/crates/ra_tools/tests/docs.rs
deleted file mode 100644
index ea3330175..000000000
--- a/crates/ra_tools/tests/docs.rs
+++ /dev/null
@@ -1,63 +0,0 @@
1use std::fs;
2use std::io::prelude::*;
3use std::io::BufReader;
4use std::path::Path;
5
6use walkdir::{DirEntry, WalkDir};
7
8use ra_tools::project_root;
9
10fn is_exclude_dir(p: &Path) -> bool {
11 let exclude_dirs = ["tests", "test_data"];
12 let mut cur_path = p;
13 while let Some(path) = cur_path.parent() {
14 if exclude_dirs.iter().any(|dir| path.ends_with(dir)) {
15 return true;
16 }
17 cur_path = path;
18 }
19
20 false
21}
22
23fn is_exclude_file(d: &DirEntry) -> bool {
24 let file_names = ["tests.rs"];
25
26 d.file_name().to_str().map(|f_n| file_names.iter().any(|name| *name == f_n)).unwrap_or(false)
27}
28
29fn is_hidden(entry: &DirEntry) -> bool {
30 entry.file_name().to_str().map(|s| s.starts_with(".")).unwrap_or(false)
31}
32
33#[test]
34fn no_docs_comments() {
35 let crates = project_root().join("crates");
36 let iter = WalkDir::new(crates);
37 for f in iter.into_iter().filter_entry(|e| !is_hidden(e)) {
38 let f = f.unwrap();
39 if f.file_type().is_dir() {
40 continue;
41 }
42 if f.path().extension().map(|it| it != "rs").unwrap_or(false) {
43 continue;
44 }
45 if is_exclude_dir(f.path()) {
46 continue;
47 }
48 if is_exclude_file(&f) {
49 continue;
50 }
51 let mut reader = BufReader::new(fs::File::open(f.path()).unwrap());
52 let mut line = String::new();
53 reader.read_line(&mut line).unwrap();
54 if !line.starts_with("//!") {
55 panic!(
56 "\nMissing docs strings\n\
57 module: {}\n\
58 Need add doc for module\n",
59 f.path().display()
60 )
61 }
62 }
63}