documentation-generator
v0.1.2
Published
A simple documentation generator
Downloads
2
Maintainers
Readme
Build documentation using a markup renderer like m42kup.
Installation
npm install documentation-generator
Example configuration using m42kup
npm install [email protected]
Example directory structure
root/
├ build/
├ src/
│ ├ file1.m42kup
│ └ dir1/
│ ├ file2.m42kup
│ └ file3.m42kup
├ documentation-generator.config.js
├ package.json
└ ...
documentation-generator.config.js
var fs = require('fs'),
path = require('path');
// Finds out the version of a module.
function getVersion(name) {
var dir = path.dirname(require.resolve(name));
while (!fs.existsSync(path.join(dir, 'package.json'))) {
dir = path.resolve(dir, '..');
}
return require(path.join(dir, 'package')).version;
}
var m42kup = require('m42kup');
var styles = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/m42kup@${getVersion('m42kup')}/web/m42kup.default.css">`;
module.exports = {
name: 'Example documentation',
src: 'src',
dst: 'build',
render: text => m42kup.render(text),
templateData: {
styles
},
list: [
{
name: 'File 1',
file: 'file1.m42kup'
},
{
name: 'Directory 1',
dir: 'dir1',
list: [
{
name: 'File 2',
file: 'file2.m42kup'
},
{
name: 'File 3',
file: 'file3.m42kup'
}
]
}
]
};
Finally, run
npx documentation-generator
at the root directory and open build/index.html
to see the generated documentation.
Refer to the documentation for more information.