Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Oct 23, 2024
1 parent fc2ec4e commit 1f6f894
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zoo"
version = "0.2.86"
version = "0.2.87"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
10 changes: 8 additions & 2 deletions src/cmd_generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,17 @@ impl crate::cmd::Command for CmdGenerateMarkdown {

impl CmdGenerateMarkdown {
fn generate(&self, ctx: &mut crate::context::Context, app: &Command, parent: &str) -> Result<()> {
let name = app.get_name();
if name == "help" {
// Skip the help command.
return Ok(());
}

let mut p = parent.to_string();
if !p.is_empty() {
p = format!("{}_{}", p, app.get_name());
p = format!("{}_{}", p, name);
} else {
p = app.get_name().to_string();
p = name.to_string();
}

let filename = format!("{p}.md");
Expand Down
9 changes: 7 additions & 2 deletions src/docs_markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ fn do_markdown(doc: &mut MarkdownDocument, app: &Command, title: &str) -> Result
doc.paragraph(about.to_string());
}

if app.has_subcommands() {
let sub_commands = app
.get_subcommands()
.filter(|c| c.get_name() != "help")
.collect::<Vec<&Command>>();
if !sub_commands.is_empty() {
doc.header("Subcommands".to_string(), pulldown_cmark::HeadingLevel::H3);

doc.0
.push(pulldown_cmark::Event::Start(pulldown_cmark::Tag::List(None)));

for cmd in app.get_subcommands() {
for cmd in sub_commands {
doc.link_in_list(
format!("{} {}", title, cmd.get_name()),
format!("./{}_{}", title.replace(' ', "_"), cmd.get_name()),
Expand All @@ -64,6 +68,7 @@ fn do_markdown(doc: &mut MarkdownDocument, app: &Command, title: &str) -> Result
}

let args = app.get_arguments().collect::<Vec<&clap::Arg>>();
println!("args: {:?}", args);
if !args.is_empty() {
doc.header("Options".to_string(), pulldown_cmark::HeadingLevel::H3);

Expand Down

0 comments on commit 1f6f894

Please sign in to comment.