Skip to content

Commit

Permalink
fix: clippy
Browse files Browse the repository at this point in the history
Small PR to fix clippy errors
  • Loading branch information
willemneal authored and gitbutler-client committed Dec 2, 2024
1 parent 1e1ae46 commit de2ecd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
29 changes: 15 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// Ensure that doc tests in the README.md file get run.
#[doc(hidden)]
#[allow(clippy::mixed_attributes_style)]
mod test_readme {
#![doc = include_str!("../README.md")]
}
Expand All @@ -33,38 +34,38 @@ pub struct MarkdownOptions {
impl MarkdownOptions {
/// Construct a default instance of `MarkdownOptions`.
pub fn new() -> Self {
return Self {
Self {
title: None,
show_footer: true,
show_table_of_contents: true,
};
}
}

/// Set a custom title to use in the generated document.
pub fn title(mut self, title: String) -> Self {
self.title = Some(title);

return self;
self
}

/// Whether to show the default footer advertising `clap-markdown`.
pub fn show_footer(mut self, show: bool) -> Self {
self.show_footer = show;

return self;
self
}

/// Whether to show the default table of contents.
pub fn show_table_of_contents(mut self, show: bool) -> Self {
self.show_table_of_contents = show;

return self;
self
}
}

impl Default for MarkdownOptions {
fn default() -> Self {
return Self::new();
Self::new()
}
}

Expand All @@ -85,12 +86,12 @@ pub fn help_markdown_custom<C: clap::CommandFactory>(
) -> String {
let command = C::command();

return help_markdown_command_custom(&command, options);
help_markdown_command_custom(&command, options)
}

/// Format the help information for `command` as Markdown.
pub fn help_markdown_command(command: &clap::Command) -> String {
return help_markdown_command_custom(command, &Default::default());
help_markdown_command_custom(command, &Default::default())
}

/// Format the help information for `command` as Markdown, with custom options.
Expand All @@ -100,7 +101,7 @@ pub fn help_markdown_command_custom(
) -> String {
let mut buffer = String::with_capacity(100);

write_help_markdown(&mut buffer, &command, options);
write_help_markdown(&mut buffer, command, options);

buffer
}
Expand Down Expand Up @@ -159,7 +160,7 @@ fn write_help_markdown(
build_table_of_contents_markdown(buffer, Vec::new(), command, 0)
.unwrap();

write!(buffer, "\n").unwrap();
writeln!(buffer).unwrap();
}

//----------------------------------------
Expand Down Expand Up @@ -335,7 +336,7 @@ fn build_command_markdown(
String::new()
} else {
let mut s = parent_command_path.join(" ");
s.push_str(" ");
s.push(' ');
s
},
command
Expand Down Expand Up @@ -373,7 +374,7 @@ fn build_command_markdown(
writeln!(buffer, "* `{title_name}` — {about}",)?;
}

write!(buffer, "\n")?;
writeln!(buffer)?;
}

//----------------------------------
Expand All @@ -387,7 +388,7 @@ fn build_command_markdown(
write_arg_markdown(buffer, pos_arg)?;
}

write!(buffer, "\n")?;
writeln!(buffer)?;
}

//----------------------------------
Expand All @@ -406,7 +407,7 @@ fn build_command_markdown(
write_arg_markdown(buffer, arg)?;
}

write!(buffer, "\n")?;
writeln!(buffer)?
}

//----------------------------------
Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn test_example_complex_app() {
assert_eq!(
clap_markdown::help_markdown_custom::<complex_app::Cli>(
&MarkdownOptions::new()
.title(format!("Some Custom Title for Complex App"))
.title("Some Custom Title for Complex App".to_string())
.show_footer(false)
.show_table_of_contents(false)
),
Expand Down

0 comments on commit de2ecd0

Please sign in to comment.