command-line-publish
Convert `command-line-usage` JSON or JavaScript ESM into HTML or SVG files
Last updated 19 days ago by brettz9 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install command-line-publish 
SYNC missed versions from official npm registry.

command-line-publish

Tool to convert command-line-args/command-line-usage JSON arrays to SVG or HTML.

Install

npm install -D command-line-publish

CLI Usage

command-line-publish <args>

or:

clp --format=html --output="cli.html" --config="jsWithSectionsExport.js"
clp --format=svg --output="cli.svg" --config="jsonWithSectionsProperty.json"

And here is the documentation generated by our use of command-line-publish on itself.

First as HTML:

And then as embeddable SVG (not copy-pasteable from Github, but it is if you visit the file directly):

cli.svg

After using the commands to generate, you can:

  • Link to the HTML, e.g., as we did above: [cli.html](https://brettz9.github.io/command-line-publish/cli.html)
  • Embed the SVG, e.g., as we did above: [![cli.svg](https://brettz9.github.io/command-line-publish/cli.svg)](cli.svg)

Note that we have configured this repository's master branch to have its contents served from Github Pages.

Programmatic usage

const {html, svg} = require('command-line-publish');

// This JavaScript (or JSON) file must export a `sections` property,
//  and for easier reusability, it is recommended that ths same file
//  define a `definitions` property for use by `command-line-args`
const {sections} = require('./path/to/config-file.js');

// The options objects are optional
svg(sections, {target: 'cli.svg', ansiToSvgOptions: {}});
html(sections, {target: 'cli.html', ansiToHtmlOptions: {}});

Here is a sampling of our own config file:

'use strict';

const pkg = require('../package.json');

const optionDefinitions = [
  {
    name: 'target', alias: 't', type: String, defaultOption: true,
    description: 'The file path target to which to write the result',
    typeLabel: '{underline file-path}'
  },
  // ... snipped
  {
    name: 'help', alias: 'h', type: Boolean,
    description: 'Display this help guide'
  }
];

const cliSections = [
  {
    // We're now actually letting `command-line-basics auto-generate the
    //  `header` now
    header: pkg.name,
    // Add italics: `{italic textToItalicize}`
    content: pkg.description +
      '\n\n{italic clp -c="configPath" [--format=svg|html] target}'
  },
  {
    // We're now actually letting `command-line-basics auto-generate the
    //  `header` now
    header: 'Options',
    optionList: optionDefinitions
  }
];

exports.definitions = optionDefinitions;
exports.sections = cliSections;

See also

Current Tags

  • 0.4.1                                ...           latest (19 days ago)

5 Versions

  • 0.4.1                                ...           19 days ago
  • 0.4.0                                ...           a month ago
  • 0.3.0                                ...           a month ago
  • 0.2.0                                ...           a month ago
  • 0.1.0                                ...           a month ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 64
Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |