Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Cleanup repo #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/target
**/*.rs.bk
Cargo.lock
173 changes: 0 additions & 173 deletions Cargo.lock

This file was deleted.

File renamed without changes.
27 changes: 19 additions & 8 deletions examples/testapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@ use clap_md::app_to_md;

fn main() {
let a = App::new("testapp")
.about("Pointless application")
.setting(AppSettings::SubcommandRequiredElseHelp)
.author("Katharina Fey <[email protected]>")
// .author("Yosh Wuyts <[email protected]")
.long_about("Lorem Ipsum bla bla bla")
.arg(Arg::with_name("debug").short("d").help("Make program output debug messages"))
.arg(Arg::with_name("output").short("o").takes_value(true).help("Output File"))
.subcommand(SubCommand::with_name("foo").arg(Arg::with_name("bar").short("b").long("barr")));
.about("Pointless application")
.setting(AppSettings::SubcommandRequiredElseHelp)
.author("Katharina Fey <[email protected]>")
// .author("Yosh Wuyts <[email protected]")
.long_about("Lorem Ipsum bla bla bla")
.arg(
Arg::with_name("debug")
.short("d")
.help("Make program output debug messages"),
)
.arg(
Arg::with_name("output")
.short("o")
.takes_value(true)
.help("Output File"),
)
.subcommand(
SubCommand::with_name("foo").arg(Arg::with_name("bar").short("b").long("barr")),
);

let markdown = app_to_md(&a, 1).unwrap();
println!("{}", markdown);
Expand Down
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ fn recursive(doc: &mut Document, app: &App, level: i32, skip_header: bool) {
/// - `level`: The level for first markdown headline. If you for example want to
/// render this beneath a `## Usage` headline in your readme, you'd want to
/// set `level` to `2`.
pub fn app_to_md<'a, 'b>(
app: &App<'a, 'b>,
level: i32,
) -> Result<String, Box<::std::error::Error>> {
pub fn app_to_md<'a, 'b>(app: &App<'a, 'b>, level: i32) -> Result<String, Box<::std::error::Error>> {
let mut document = Document(Vec::new());
recursive(&mut document, app, level, level > 1);
let mut result = String::new();
cmark(document.0.iter(), &mut result, None)?;
Ok(result)
}