-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
520 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
#![cfg(feature = "derive")] | ||
|
||
use clap::CommandFactory; | ||
use clap_derive::Parser; | ||
use snapbox::file; | ||
|
||
macro_rules! assert_help { | ||
($Command:ty, $filename:literal) => {{ | ||
let help = <$Command>::command().render_long_help().ansi().to_string(); | ||
snapbox::assert_data_eq!(help, file![$filename]); | ||
}}; | ||
} | ||
|
||
#[test] | ||
fn headers() { | ||
/// # This is a header | ||
/// ## second level | ||
/// ### `additional` *styling **on ~top~ of** it* | ||
/// regular paragraph | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/headers.term.svg"); | ||
} | ||
|
||
#[test] | ||
fn inline_styles() { | ||
/// *emphasis* **bold** ~strike through~ `code` | ||
/// | ||
/// *all **of ~them `combined` in~ one** line* | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/inline_styles.term.svg"); | ||
} | ||
|
||
#[test] | ||
fn links() { | ||
/// <https://example.com/literal> | ||
/// | ||
/// [with name](https://example.com/with%20name) | ||
/// | ||
///  | ||
/// | ||
/// [referencing][reference] | ||
/// | ||
/// [reference]: https://example.com/reference | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/links.term.svg"); | ||
} | ||
|
||
#[test] | ||
fn html() { | ||
/// <html> | ||
/// <is> | ||
/// <used> | ||
/// </verbatim> | ||
/// </html> | ||
/// | ||
/// <inline>html</as-well> | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/html.term.svg"); | ||
} | ||
|
||
#[test] | ||
fn blocks() { | ||
/// ```rust | ||
/// This is a *fenced* code block. | ||
/// | ||
/// There is not much going on in terms of **styling**. | ||
/// ``` | ||
/// | ||
/// --- | ||
/// | ||
/// Code blocks can also be initiated through | ||
/// Indentation. | ||
/// | ||
/// > This is a block quote. | ||
/// > **Regular ~styling *should* work~ here.** | ||
/// > | ||
/// > # even headings | ||
/// > and regular paragraphs. | ||
/// > | ||
/// > - lists | ||
/// > - are | ||
/// > | ||
/// > 1. also | ||
/// > 1. supported | ||
/// > | ||
/// > > nesting them | ||
/// > > > also works (not) | ||
/// | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/blocks.term.svg"); | ||
} | ||
|
||
#[test] | ||
fn lists() { | ||
/// Lists: | ||
/// | ||
/// - unordered | ||
/// - bullet | ||
/// - lists | ||
/// - with multiple | ||
/// - levels | ||
/// | ||
/// 0. numeric lists | ||
/// 1. only care | ||
/// 1. about the initial number | ||
/// 2. 5. and count from there | ||
/// 7. anything goes | ||
/// 3. though they need an empty line | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/lists.term.svg"); | ||
} | ||
|
||
#[test] | ||
fn paragraphs() { | ||
/// Paragraphs are separated by empty lines. | ||
/// All lines will be joined onto one. | ||
/// | ||
/// The first paragraph is used as short help by clap.\ | ||
/// backslashes can be used to insert hard line breaks. | ||
/// | ||
/// | these | can |\ | ||
/// | ----- | ----- |\ | ||
/// | be | used |\ | ||
/// | for | tables| | ||
/// | ||
/// Because tables are not yet supported. | ||
/// | ||
#[doc = "You can also use trailing spaces for hard breaks, \nbut this is not really recommended."] | ||
#[derive(Parser)] | ||
struct Command; | ||
|
||
assert_help!(Command, "snapshots/paragraphs.term.svg"); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.