diff --git a/cli.js b/cli.js index 80143b93..4411b00a 100755 --- a/cli.js +++ b/cli.js @@ -128,7 +128,6 @@ const docs = pipe( ); const schemaPathMap = {}; -const metaElements = argv.m; const schemaPath = argv.d; const schemaDir = argv.x; const target = fs.statSync(schemaPath); @@ -163,7 +162,9 @@ readdirp.promise(schemaPath, { root: schemaPath, fileFilter: `*.${schemaExtensio generate, // generate Markdown ASTs - build({}), + build({ + header: argv.h + }), // build readme readme({ diff --git a/lib/markdownBuilder.js b/lib/markdownBuilder.js index d5e5f967..3c9f8942 100644 --- a/lib/markdownBuilder.js +++ b/lib/markdownBuilder.js @@ -11,18 +11,26 @@ */ const { each, values } = require('ferrum'); const { - root, paragraph, text, heading, brk, separator + root, paragraph, text, heading, code } = require('mdast-builder'); -function build({ }) { - +function build({ header }) { + function makeheader(schema) { + if (header) { + return [ + heading(1, text(schema.title)), + paragraph(code('txt', schema.id + (schema.pointer ? '#' + schema.pointer : ''))), + schema.longdescription + ] + } + return []; + } return (schemas) => { // eslint-disable-next-line no-return-assign, no-param-reassign each(values(schemas), schema => schema.markdown = root([ // todo add more elements - heading(1, text(schema.title)), - paragraph(text('This is a schema.')), + ...makeheader(schema) ])); return schemas; };