open-vault/ui/scripts/gen-story-md.js
Madalyn 43f4c5532d use ember-power-select-with-create instead of ember-power-select (#6728)
* use ember-power-select-with-create instead of ember-power-select

* add custom Add message to clarify whether you need a name or ID

* add search-select to storybook

* add wormhole div for ember-basic-dropdown

* add search-select to storybook

* make sure knobs are working

* remove unused code
2019-06-03 15:25:59 -05:00

37 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/* eslint-disable */
const fs = require('fs');
const jsdoc2md = require('jsdoc-to-markdown');
var args = process.argv.slice(2);
const name = args[0];
const addonOrEngine = args[1];
const inputFile = addonOrEngine
? `lib/${addonOrEngine}/addon/components/${name}.js`
: `app/components/${name}.js`;
const outputFile = `stories/${name}.md`;
const component = name
.split('-')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join('');
const options = {
files: inputFile,
template: fs.readFileSync('./lib/story-md.hbs', 'utf8'),
'example-lang': 'js',
};
let md = jsdoc2md.renderSync(options);
const pageBreakIndex = md.lastIndexOf('---'); //this is our last page break
const seeLinks = `**See**
- [Uses of ${component}](https://github.com/hashicorp/vault/search?l=Handlebars&q=${component}+OR+${name})
- [${component} Source Code](https://github.com/hashicorp/vault/blob/master/ui/${inputFile})
`;
const generatedWarning = `<!--THIS FILE IS AUTO GENERATED. This file is generated from JSDoc comments in ${inputFile}. To make changes, first edit that file and run "yarn gen-story-md ${name}" to re-generate the content.-->
`;
md = generatedWarning + md.slice(0, pageBreakIndex) + seeLinks + md.slice(pageBreakIndex);
fs.writeFileSync(outputFile, md);