Home Reference Source Test
public class | source

Presenter

Generates markdown documentation for commands.

Example:

Presenter.generateFor({
     command: 'release',
     description: 'Bundles source files for release.',
     options: [{ flag: '-f, --force', description: "Overwrite target file" }],
     examples: [{ command: '-o path/to/target', description: "Changes output directory" }]
});
// => ## release
//    Bundles source files for release.
//
//    ### Options
//    **-f, --force**: Overwrite target file
//
//    ### Examples
//    $ shinka release -o path/to/target     # Changes output directory

Test:

Static Member Summary

Static Public Members
public static

Generates documentation for given command.

Static Method Summary

Static Public Methods
public static

Transforms examples to list of strings.

public static

Transforms options to list of strings.

Static Public Members

public static generateFor(cmd: Command): string: * source

Generates documentation for given command.

Return:

string

Generated documentation

Example:

Presenter.generateFor({
     command: 'release',
     description: 'Bundles source files for release.'
});
// => ## Release
//    Bundles source files for release.

Test:

Static Public Methods

public static buildExamples(cmd: Command): string[] source

Transforms examples to list of strings.

Params:

NameTypeAttributeDescription
cmd Command
cmd.examples Example[]
cmd.command string

Return:

string[]

Example:

Presenter.buildExamples({
     command: "release",
     examples: [{ command: '-o path/to/target', description: "Changes output directory" }]
});
// => ['### Examples',
//     '```shell',
//     '$ release -o path/to/target    # Changes output directory',
//     '```']

Test:

public static buildOptions(cmd: Command): string[] source

Transforms options to list of strings.

Params:

NameTypeAttributeDescription
cmd Command
cmd.options Option[]

Return:

string[]

Example:

Presenter.buildOptions({
     options: [{ flag: '-f, --force', description: "Overwrite target file" }]
});
// => ['### Options', **-f, --force**: Overwrite target file']

Test: