diff options
-rw-r--r-- | crates/ra_cfg/src/lib.rs | 5 | ||||
-rw-r--r-- | crates/ra_fmt/src/lib.rs | 5 | ||||
-rw-r--r-- | xtask/tests/tidy-tests/docs.rs | 49 |
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 | |||
3 | mod cfg_expr; | ||
4 | |||
2 | use std::iter::IntoIterator; | 5 | use std::iter::IntoIterator; |
3 | 6 | ||
4 | use ra_syntax::SmolStr; | 7 | use ra_syntax::SmolStr; |
5 | use rustc_hash::FxHashSet; | 8 | use rustc_hash::FxHashSet; |
6 | 9 | ||
7 | mod cfg_expr; | ||
8 | |||
9 | pub use cfg_expr::{parse_cfg, CfgExpr}; | 10 | pub 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 | |
3 | use std::iter::successors; | ||
4 | |||
3 | use itertools::Itertools; | 5 | use itertools::Itertools; |
4 | use ra_syntax::{ | 6 | use 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 | }; |
10 | use std::iter::successors; | ||
11 | 12 | ||
12 | pub fn reindent(text: &str, indent: &str) -> String { | 13 | pub 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 @@ | |||
1 | use std::fs; | 1 | use std::{collections::HashMap, fs, io::prelude::*, io::BufReader, path::Path}; |
2 | use std::io::prelude::*; | ||
3 | use std::io::BufReader; | ||
4 | use std::path::Path; | ||
5 | 2 | ||
6 | use walkdir::{DirEntry, WalkDir}; | 3 | use walkdir::{DirEntry, WalkDir}; |
7 | |||
8 | use xtask::project_root; | 4 | use xtask::project_root; |
9 | 5 | ||
10 | fn is_exclude_dir(p: &Path) -> bool { | 6 | fn 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 | } |