mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Disallow regressing crate docs
This commit is contained in:
parent
d09e5a3d9e
commit
30bf7e43db
3 changed files with 49 additions and 10 deletions
|
@ -1,11 +1,12 @@
|
|||
//! ra_cfg defines conditional compiling options, `cfg` attibute parser and evaluator
|
||||
|
||||
mod cfg_expr;
|
||||
|
||||
use std::iter::IntoIterator;
|
||||
|
||||
use ra_syntax::SmolStr;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
mod cfg_expr;
|
||||
|
||||
pub use cfg_expr::{parse_cfg, CfgExpr};
|
||||
|
||||
/// Configuration options used for conditional compilition on items with `cfg` attributes.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
//! This crate provides some utilities for indenting rust code.
|
||||
//!
|
||||
|
||||
use std::iter::successors;
|
||||
|
||||
use itertools::Itertools;
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode, AstToken},
|
||||
|
@ -7,7 +9,6 @@ use ra_syntax::{
|
|||
SyntaxKind::*,
|
||||
SyntaxNode, SyntaxToken, T,
|
||||
};
|
||||
use std::iter::successors;
|
||||
|
||||
pub fn reindent(text: &str, indent: &str) -> String {
|
||||
let indent = format!("\n{}", indent);
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
use std::fs;
|
||||
use std::io::prelude::*;
|
||||
use std::io::BufReader;
|
||||
use std::path::Path;
|
||||
use std::{collections::HashMap, fs, io::prelude::*, io::BufReader, path::Path};
|
||||
|
||||
use walkdir::{DirEntry, WalkDir};
|
||||
|
||||
use xtask::project_root;
|
||||
|
||||
fn is_exclude_dir(p: &Path) -> bool {
|
||||
|
@ -37,6 +33,7 @@ fn no_docs_comments() {
|
|||
let crates = project_root().join("crates");
|
||||
let iter = WalkDir::new(crates);
|
||||
let mut missing_docs = Vec::new();
|
||||
let mut contains_fixme = Vec::new();
|
||||
for f in iter.into_iter().filter_entry(|e| !is_hidden(e)) {
|
||||
let f = f.unwrap();
|
||||
if f.file_type().is_dir() {
|
||||
|
@ -54,7 +51,12 @@ fn no_docs_comments() {
|
|||
let mut reader = BufReader::new(fs::File::open(f.path()).unwrap());
|
||||
let mut line = String::new();
|
||||
reader.read_line(&mut line).unwrap();
|
||||
if !line.starts_with("//!") {
|
||||
|
||||
if line.starts_with("//!") {
|
||||
if line.contains("FIXME") {
|
||||
contains_fixme.push(f.path().to_path_buf())
|
||||
}
|
||||
} else {
|
||||
missing_docs.push(f.path().display().to_string());
|
||||
}
|
||||
}
|
||||
|
@ -65,4 +67,39 @@ fn no_docs_comments() {
|
|||
missing_docs.join("\n")
|
||||
)
|
||||
}
|
||||
|
||||
let whitelist = [
|
||||
"ra_batch",
|
||||
"ra_cli",
|
||||
"ra_db",
|
||||
"ra_hir",
|
||||
"ra_hir_expand",
|
||||
"ra_hir_def",
|
||||
"ra_ide_api",
|
||||
"ra_lsp_server",
|
||||
"ra_mbe",
|
||||
"ra_parser",
|
||||
"ra_prof",
|
||||
"ra_project_model",
|
||||
"ra_syntax",
|
||||
"ra_text_edit",
|
||||
"ra_tt",
|
||||
];
|
||||
|
||||
let mut has_fixmes = whitelist.iter().map(|it| (*it, false)).collect::<HashMap<&str, bool>>();
|
||||
'outer: for path in contains_fixme {
|
||||
for krate in whitelist.iter() {
|
||||
if path.components().any(|it| it.as_os_str() == *krate) {
|
||||
has_fixmes.insert(krate, true);
|
||||
continue 'outer;
|
||||
}
|
||||
}
|
||||
panic!("FIXME doc in a fully-documented crate: {}", path.display())
|
||||
}
|
||||
|
||||
for (krate, has_fixme) in has_fixmes.iter() {
|
||||
if !has_fixme {
|
||||
panic!("crate {} is fully documented, remove it from the white list", krate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue