aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_cfg/src/lib.rs5
-rw-r--r--crates/ra_fmt/src/lib.rs5
-rw-r--r--xtask/tests/tidy-tests/docs.rs49
3 files changed, 49 insertions, 10 deletions
diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs
index 1bee3eb99..51d953f6e 100644
--- a/crates/ra_cfg/src/lib.rs
+++ b/crates/ra_cfg/src/lib.rs
@@ -1,11 +1,12 @@
1//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator 1//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator
2
3mod cfg_expr;
4
2use std::iter::IntoIterator; 5use std::iter::IntoIterator;
3 6
4use ra_syntax::SmolStr; 7use ra_syntax::SmolStr;
5use rustc_hash::FxHashSet; 8use rustc_hash::FxHashSet;
6 9
7mod cfg_expr;
8
9pub use cfg_expr::{parse_cfg, CfgExpr}; 10pub use cfg_expr::{parse_cfg, CfgExpr};
10 11
11/// Configuration options used for conditional compilition on items with `cfg` attributes. 12/// Configuration options used for conditional compilition on items with `cfg` attributes.
diff --git a/crates/ra_fmt/src/lib.rs b/crates/ra_fmt/src/lib.rs
index e22ac9753..a30ed4cbb 100644
--- a/crates/ra_fmt/src/lib.rs
+++ b/crates/ra_fmt/src/lib.rs
@@ -1,5 +1,7 @@
1//! This crate provides some utilities for indenting rust code. 1//! This crate provides some utilities for indenting rust code.
2//! 2
3use std::iter::successors;
4
3use itertools::Itertools; 5use itertools::Itertools;
4use ra_syntax::{ 6use ra_syntax::{
5 ast::{self, AstNode, AstToken}, 7 ast::{self, AstNode, AstToken},
@@ -7,7 +9,6 @@ use ra_syntax::{
7 SyntaxKind::*, 9 SyntaxKind::*,
8 SyntaxNode, SyntaxToken, T, 10 SyntaxNode, SyntaxToken, T,
9}; 11};
10use std::iter::successors;
11 12
12pub fn reindent(text: &str, indent: &str) -> String { 13pub fn reindent(text: &str, indent: &str) -> String {
13 let indent = format!("\n{}", indent); 14 let indent = format!("\n{}", indent);
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}