Fixing clippy lints
This commit is contained in:
parent
56c225bd34
commit
2fbe3ba930
|
@ -75,10 +75,10 @@ fn create_missing(src_dir: &Path, summary: &Summary) -> Result<()> {
|
||||||
/// [`iter()`]: #method.iter
|
/// [`iter()`]: #method.iter
|
||||||
/// [`for_each_mut()`]: #method.for_each_mut
|
/// [`for_each_mut()`]: #method.for_each_mut
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[non_exhaustive]
|
||||||
pub struct Book {
|
pub struct Book {
|
||||||
/// The sections in this book.
|
/// The sections in this book.
|
||||||
pub sections: Vec<BookItem>,
|
pub sections: Vec<BookItem>,
|
||||||
__non_exhaustive: (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Book {
|
impl Book {
|
||||||
|
@ -226,10 +226,7 @@ pub(crate) fn load_book_from_disk<P: AsRef<Path>>(summary: &Summary, src_dir: P)
|
||||||
chapters.push(chapter);
|
chapters.push(chapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Book {
|
Ok(Book { sections: chapters })
|
||||||
sections: chapters,
|
|
||||||
__non_exhaustive: (),
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_summary_item<P: AsRef<Path> + Clone>(
|
fn load_summary_item<P: AsRef<Path> + Clone>(
|
||||||
|
|
|
@ -839,7 +839,7 @@ mod tests {
|
||||||
.and_then(Value::as_str)
|
.and_then(Value::as_str)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(html, "html");
|
assert_eq!(html, "html");
|
||||||
let html_renderer = HtmlHandlebars::default();
|
let html_renderer = HtmlHandlebars;
|
||||||
let pre = LinkPreprocessor::new();
|
let pre = LinkPreprocessor::new();
|
||||||
|
|
||||||
let should_run = preprocessor_should_run(&pre, &html_renderer, &cfg);
|
let should_run = preprocessor_should_run(&pre, &html_renderer, &cfg);
|
||||||
|
|
|
@ -566,9 +566,7 @@ fn get_last_link(links: &mut [SummaryItem]) -> Result<(usize, &mut Link)> {
|
||||||
links
|
links
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l)))
|
.filter_map(|(i, item)| item.maybe_link_mut().map(|l| (i, l))).next_back()
|
||||||
.rev()
|
|
||||||
.next()
|
|
||||||
.ok_or_else(||
|
.ok_or_else(||
|
||||||
anyhow::anyhow!("Unable to get last link because the list of SummaryItems doesn't contain any Links")
|
anyhow::anyhow!("Unable to get last link because the list of SummaryItems doesn't contain any Links")
|
||||||
)
|
)
|
||||||
|
|
|
@ -646,21 +646,13 @@ impl Default for Playground {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Configuration for tweaking how the the HTML renderer handles code blocks.
|
/// Configuration for tweaking how the the HTML renderer handles code blocks.
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(default, rename_all = "kebab-case")]
|
#[serde(default, rename_all = "kebab-case")]
|
||||||
pub struct Code {
|
pub struct Code {
|
||||||
/// A prefix string to hide lines per language (one or more chars).
|
/// A prefix string to hide lines per language (one or more chars).
|
||||||
pub hidelines: HashMap<String, String>,
|
pub hidelines: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Code {
|
|
||||||
fn default() -> Code {
|
|
||||||
Code {
|
|
||||||
hidelines: HashMap::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Configuration of the search functionality of the HTML renderer.
|
/// Configuration of the search functionality of the HTML renderer.
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(default, rename_all = "kebab-case")]
|
#[serde(default, rename_all = "kebab-case")]
|
||||||
|
|
|
@ -62,7 +62,7 @@ fn main() {
|
||||||
fn create_clap_command() -> Command {
|
fn create_clap_command() -> Command {
|
||||||
let app = Command::new(crate_name!())
|
let app = Command::new(crate_name!())
|
||||||
.about(crate_description!())
|
.about(crate_description!())
|
||||||
.author("Mathieu David <mathieudavid@mathieudavid.org>")
|
.author("Mathieu David <mathieudavid@mathieudavid.org> and edited by Mauro Gentile <gents83@gmail.com>")
|
||||||
.version(VERSION)
|
.version(VERSION)
|
||||||
.propagate_version(true)
|
.propagate_version(true)
|
||||||
.arg_required_else_help(true)
|
.arg_required_else_help(true)
|
||||||
|
|
|
@ -823,7 +823,7 @@ fn build_header_links(html: &str) -> String {
|
||||||
|
|
||||||
// Ignore .menu-title because now it's getting detected by the regex.
|
// Ignore .menu-title because now it's getting detected by the regex.
|
||||||
if let Some(classes) = caps.get(3) {
|
if let Some(classes) = caps.get(3) {
|
||||||
for class in classes.as_str().split(" ") {
|
for class in classes.as_str().split(' ') {
|
||||||
if IGNORE_CLASS.contains(&class) {
|
if IGNORE_CLASS.contains(&class) {
|
||||||
return caps[0].to_string();
|
return caps[0].to_string();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,14 +73,12 @@ pub fn create_file(path: &Path) -> Result<File> {
|
||||||
|
|
||||||
/// Removes all the content of a directory but not the directory itself
|
/// Removes all the content of a directory but not the directory itself
|
||||||
pub fn remove_dir_content(dir: &Path) -> Result<()> {
|
pub fn remove_dir_content(dir: &Path) -> Result<()> {
|
||||||
for item in fs::read_dir(dir)? {
|
for item in (fs::read_dir(dir)?).flatten() {
|
||||||
if let Ok(item) = item {
|
let item = item.path();
|
||||||
let item = item.path();
|
if item.is_dir() {
|
||||||
if item.is_dir() {
|
fs::remove_dir_all(item)?;
|
||||||
fs::remove_dir_all(item)?;
|
} else {
|
||||||
} else {
|
fs::remove_file(item)?;
|
||||||
fs::remove_file(item)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -17,7 +17,7 @@ fn example_supports_whatever() {
|
||||||
|
|
||||||
let got = cmd.supports_renderer("whatever");
|
let got = cmd.supports_renderer("whatever");
|
||||||
|
|
||||||
assert_eq!(got, true);
|
assert!(got);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -26,7 +26,7 @@ fn example_doesnt_support_not_supported() {
|
||||||
|
|
||||||
let got = cmd.supports_renderer("not-supported");
|
let got = cmd.supports_renderer("not-supported");
|
||||||
|
|
||||||
assert_eq!(got, false);
|
assert!(!got);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -966,5 +966,5 @@ fn custom_header_attributes() {
|
||||||
r##"<h2 id="heading-with-classes" class="class1 class2"><a class="header" href="#heading-with-classes">Heading with classes</a></h2>"##,
|
r##"<h2 id="heading-with-classes" class="class1 class2"><a class="header" href="#heading-with-classes">Heading with classes</a></h2>"##,
|
||||||
r##"<h2 id="both" class="class1 class2"><a class="header" href="#both">Heading with id and classes</a></h2>"##,
|
r##"<h2 id="both" class="class1 class2"><a class="header" href="#both">Heading with id and classes</a></h2>"##,
|
||||||
];
|
];
|
||||||
assert_contains_strings(&contents, summary_strings);
|
assert_contains_strings(contents, summary_strings);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue