mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 13:47:52 +00:00
34 lines
934 B
TypeScript
34 lines
934 B
TypeScript
|
import capitanodoc = require('../../capitanodoc');
|
||
|
import * as _ from 'lodash';
|
||
|
import * as path from 'path';
|
||
|
import * as markdown from './markdown';
|
||
|
import { Document, Category } from './doc-types';
|
||
|
|
||
|
const result = <Document> {};
|
||
|
result.title = capitanodoc.title;
|
||
|
result.introduction = capitanodoc.introduction;
|
||
|
result.categories = [];
|
||
|
|
||
|
for (let commandCategory of capitanodoc.categories) {
|
||
|
const category = <Category> {};
|
||
|
category.title = commandCategory.title;
|
||
|
category.commands = [];
|
||
|
|
||
|
for (let file of commandCategory.files) {
|
||
|
const actions: any = require(path.join(process.cwd(), file));
|
||
|
|
||
|
if (actions.signature != null) {
|
||
|
category.commands.push(_.omit(actions, 'action'));
|
||
|
} else {
|
||
|
for (let actionName in actions) {
|
||
|
const actionCommand = actions[actionName];
|
||
|
category.commands.push(_.omit(actionCommand, 'action'));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
result.categories.push(category);
|
||
|
}
|
||
|
|
||
|
console.log(markdown.render(result));
|