Giter Club home page Giter Club logo

clap-markdown's Introduction

clap-markdown

Crates.io License Documentation

Automatically generate Markdown documentation for clap command-line tools.

Examples

Generate Markdown text for a basic clap app:

#[derive(clap::Parser)]
struct Cli {
    #[arg()]
    name: String,
}

let markdown: String = clap_markdown::help_markdown::<Cli>();

Generated Markdown Examples:

See clap example programs and the corresponding Markdown generated by clap-markdown:

Program Markdown
./complex_app.rs complex-app.md

Usage Convention: CommandLineHelp.md

This section describes a suggested convention for using clap-markdown to generate a CommandLineHelp.md file, which can be committed to source control and viewed as online documentation.

  1. Add a hidden --markdown-help option to your clap application:
use clap::Parser;

#[derive(Parser)]
struct Cli {
    #[arg(long, hide = true)]
    markdown_help: bool,
}

fn main() {
    let args = Cli::parse();

    // Invoked as: `$ my-app --markdown-help`
    if args.markdown_help {
        clap_markdown::print_help_markdown::<Cli>();
    }
}
  1. Invoke --markdown-help to generate a CommandLineHelp.md file:
$ cargo run -- --markdown-help > docs/CommandLineHelp.md
  1. Save CommandLineHelp.md in git, and link to it from the project's README.md or other relevant documentation.

For projects that have multiple associated executables, consider using the command name as a suffix. For example: CommandLineHelp-your-app.md, CommandLineHelp-other-app.md.

Comitting CommandLineHelp.md to version control makes it easy to track user-visible changes to the command-line interface.

Projects using clap-markdown

The following projects use clap-markdown to generate a CommandLineHelp.md reference document:

To request the addition of a project to this list, please file an issue.

Compatibility with clap

When this crate adds support for a new MAJOR version of clap, the MAJOR version number of clap-markdown will be changed.

Compability History:

clap-markdown clap
v0.0.1 – v0.1.3 "4.*.*"

License

Licensed under either of

at your option.

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See Development.md for instructions on how to perform common development tasks.

See Maintenance.md for instructions on how to maintain this project.

clap-markdown's People

Contributors

connorgray avatar wackazong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.