Clippy
This commit is contained in:
parent
94634fe87d
commit
047ce32efd
|
@ -112,7 +112,7 @@ impl Library {
|
||||||
subsections
|
subsections
|
||||||
// Using the original filename to work for multi-lingual sections
|
// Using the original filename to work for multi-lingual sections
|
||||||
.entry(grand_parent.join(§ion.file.filename))
|
.entry(grand_parent.join(§ion.file.filename))
|
||||||
.or_insert_with(|| vec![])
|
.or_insert_with(Vec::new)
|
||||||
.push(section.file.path.clone());
|
.push(section.file.path.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ impl Library {
|
||||||
parent_is_transparent = section.meta.transparent;
|
parent_is_transparent = section.meta.transparent;
|
||||||
}
|
}
|
||||||
page.ancestors =
|
page.ancestors =
|
||||||
ancestors.get(&parent_section_path).cloned().unwrap_or_else(|| vec![]);
|
ancestors.get(&parent_section_path).cloned().unwrap_or_else(Vec::new);
|
||||||
// Don't forget to push the actual parent
|
// Don't forget to push the actual parent
|
||||||
page.ancestors.push(*section_key);
|
page.ancestors.push(*section_key);
|
||||||
|
|
||||||
|
@ -201,8 +201,7 @@ impl Library {
|
||||||
children.sort_by(|a, b| sections_weight[a].cmp(§ions_weight[b]));
|
children.sort_by(|a, b| sections_weight[a].cmp(§ions_weight[b]));
|
||||||
section.subsections = children;
|
section.subsections = children;
|
||||||
}
|
}
|
||||||
section.ancestors =
|
section.ancestors = ancestors.get(§ion.file.path).cloned().unwrap_or_else(Vec::new);
|
||||||
ancestors.get(§ion.file.path).cloned().unwrap_or_else(|| vec![]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ pub fn find_taxonomies(config: &Config, library: &Library) -> Result<Vec<Taxonom
|
||||||
.get_mut(&taxo_key)
|
.get_mut(&taxo_key)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.entry(term.to_string())
|
.entry(term.to_string())
|
||||||
.or_insert_with(|| vec![])
|
.or_insert_with(Vec::new)
|
||||||
.push(key);
|
.push(key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -210,14 +210,14 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Start(Tag::CodeBlock(ref kind)) => {
|
Event::Start(Tag::CodeBlock(ref kind)) => {
|
||||||
let mut language = None;
|
let language = match kind {
|
||||||
match kind {
|
|
||||||
CodeBlockKind::Fenced(fence_info) => {
|
CodeBlockKind::Fenced(fence_info) => {
|
||||||
let fence_info = fence::FenceSettings::new(fence_info);
|
let fence_info = fence::FenceSettings::new(fence_info);
|
||||||
language = fence_info.language;
|
fence_info.language
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
if !context.config.highlight_code() {
|
if !context.config.highlight_code() {
|
||||||
if let Some(lang) = language {
|
if let Some(lang) = language {
|
||||||
let html = format!(r#"<pre><code class="language-{}">"#, lang);
|
let html = format!(r#"<pre><code class="language-{}">"#, lang);
|
||||||
|
@ -296,8 +296,7 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
|
||||||
if markup.contains("<!-- more -->") {
|
if markup.contains("<!-- more -->") {
|
||||||
has_summary = true;
|
has_summary = true;
|
||||||
Event::Html(CONTINUE_READING.into())
|
Event::Html(CONTINUE_READING.into())
|
||||||
} else {
|
} else if in_html_block && markup.contains("</pre>") {
|
||||||
if in_html_block && markup.contains("</pre>") {
|
|
||||||
in_html_block = false;
|
in_html_block = false;
|
||||||
Event::Html(markup.replacen("</pre>", "", 1).into())
|
Event::Html(markup.replacen("</pre>", "", 1).into())
|
||||||
} else if markup.contains("pre data-shortcode") {
|
} else if markup.contains("pre data-shortcode") {
|
||||||
|
@ -313,7 +312,6 @@ pub fn markdown_to_html(content: &str, context: &RenderContext) -> Result<Render
|
||||||
event
|
event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
_ => event,
|
_ => event,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -205,7 +205,7 @@ impl Site {
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip hidden files and non md files
|
// skip hidden files and non md files
|
||||||
if !path.is_dir() && (!file_name.ends_with(".md") || file_name.starts_with(".")) {
|
if !path.is_dir() && (!file_name.ends_with(".md") || file_name.starts_with('.')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ impl GetTaxonomyUrl {
|
||||||
}
|
}
|
||||||
taxonomies.insert(format!("{}-{}", taxo.kind.name, taxo.kind.lang), items);
|
taxonomies.insert(format!("{}-{}", taxo.kind.name, taxo.kind.lang), items);
|
||||||
}
|
}
|
||||||
Self { taxonomies, default_lang: default_lang.to_string(), slugify: slugify }
|
Self { taxonomies, default_lang: default_lang.to_string(), slugify }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl TeraFn for GetTaxonomyUrl {
|
impl TeraFn for GetTaxonomyUrl {
|
||||||
|
|
|
@ -238,7 +238,7 @@ pub fn serve(
|
||||||
// Stop right there if we can't bind to the address
|
// Stop right there if we can't bind to the address
|
||||||
let bind_address: SocketAddrV4 = address.parse().unwrap();
|
let bind_address: SocketAddrV4 = address.parse().unwrap();
|
||||||
if (TcpListener::bind(&bind_address)).is_err() {
|
if (TcpListener::bind(&bind_address)).is_err() {
|
||||||
return Err(format!("Cannot start server on address {}.", address))?;
|
return Err(format!("Cannot start server on address {}.", address).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// An array of (path, bool, bool) where the path should be watched for changes, and the boolean value
|
// An array of (path, bool, bool) where the path should be watched for changes, and the boolean value
|
||||||
|
@ -442,10 +442,7 @@ pub fn serve(
|
||||||
loop {
|
loop {
|
||||||
match rx.recv() {
|
match rx.recv() {
|
||||||
Ok(event) => {
|
Ok(event) => {
|
||||||
let can_do_fast_reload = match event {
|
let can_do_fast_reload = !matches!(event, Remove(_));
|
||||||
Remove(_) => false,
|
|
||||||
_ => true,
|
|
||||||
};
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
// Intellij does weird things on edit, chmod is there to count those changes
|
// Intellij does weird things on edit, chmod is there to count those changes
|
||||||
|
@ -505,12 +502,10 @@ pub fn serve(
|
||||||
site = s;
|
site = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(s) = recreate_site() {
|
||||||
if let Some(s) = recreate_site() {
|
|
||||||
site = s;
|
site = s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
(ChangeKind::Templates, partial_path) => {
|
(ChangeKind::Templates, partial_path) => {
|
||||||
let msg = if path.is_dir() {
|
let msg = if path.is_dir() {
|
||||||
format!(
|
format!(
|
||||||
|
|
Loading…
Reference in a new issue