aboutsummaryrefslogtreecommitdiff
path: root/xtask/tests
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/tests')
-rw-r--r--xtask/tests/tidy-tests/docs.rs49
1 files changed, 43 insertions, 6 deletions
diff --git a/xtask/tests/tidy-tests/docs.rs b/xtask/tests/tidy-tests/docs.rs
index 227937f46..141219860 100644
--- a/xtask/tests/tidy-tests/docs.rs
+++ b/xtask/tests/tidy-tests/docs.rs
@@ -1,10 +1,6 @@
1use std::fs; 1use std::{collections::HashMap, fs, io::prelude::*, io::BufReader, path::Path};
2use std::io::prelude::*;
3use std::io::BufReader;
4use std::path::Path;
5 2
6use walkdir::{DirEntry, WalkDir}; 3use walkdir::{DirEntry, WalkDir};
7
8use xtask::project_root; 4use xtask::project_root;
9 5
10fn is_exclude_dir(p: &Path) -> bool { 6fn is_exclude_dir(p: &Path) -> bool {
@@ -37,6 +33,7 @@ fn no_docs_comments() {
37 let crates = project_root().join("crates"); 33 let crates = project_root().join("crates");
38 let iter = WalkDir::new(crates); 34 let iter = WalkDir::new(crates);
39 let mut missing_docs = Vec::new(); 35 let mut missing_docs = Vec::new();
36 let mut contains_fixme = Vec::new();
40 for f in iter.into_iter().filter_entry(|e| !is_hidden(e)) { 37 for f in iter.into_iter().filter_entry(|e| !is_hidden(e)) {
41 let f = f.unwrap(); 38 let f = f.unwrap();
42 if f.file_type().is_dir() { 39 if f.file_type().is_dir() {
@@ -54,7 +51,12 @@ fn no_docs_comments() {
54 let mut reader = BufReader::new(fs::File::open(f.path()).unwrap()); 51 let mut reader = BufReader::new(fs::File::open(f.path()).unwrap());
55 let mut line = String::new(); 52 let mut line = String::new();
56 reader.read_line(&mut line).unwrap(); 53 reader.read_line(&mut line).unwrap();
57 if !line.starts_with("//!") { 54
55 if line.starts_with("//!") {
56 if line.contains("FIXME") {
57 contains_fixme.push(f.path().to_path_buf())
58 }
59 } else {
58 missing_docs.push(f.path().display().to_string()); 60 missing_docs.push(f.path().display().to_string());
59 } 61 }
60 } 62 }
@@ -65,4 +67,39 @@ fn no_docs_comments() {
65 missing_docs.join("\n") 67 missing_docs.join("\n")
66 ) 68 )
67 } 69 }
70
71 let whitelist = [
72 "ra_batch",
73 "ra_cli",
74 "ra_db",
75 "ra_hir",
76 "ra_hir_expand",
77 "ra_hir_def",
78 "ra_ide_api",
79 "ra_lsp_server",
80 "ra_mbe",
81 "ra_parser",
82 "ra_prof",
83 "ra_project_model",
84 "ra_syntax",
85 "ra_text_edit",
86 "ra_tt",
87 ];
88
89 let mut has_fixmes = whitelist.iter().map(|it| (*it, false)).collect::<HashMap<&str, bool>>();
90 'outer: for path in contains_fixme {
91 for krate in whitelist.iter() {
92 if path.components().any(|it| it.as_os_str() == *krate) {
93 has_fixmes.insert(krate, true);
94 continue 'outer;
95 }
96 }
97 panic!("FIXME doc in a fully-documented crate: {}", path.display())
98 }
99
100 for (krate, has_fixme) in has_fixmes.iter() {
101 if !has_fixme {
102 panic!("crate {} is fully documented, remove it from the white list", krate)
103 }
104 }
68} 105}