Skip to content

Commit

Permalink
feat(markdown): add header surpression
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Dec 3, 2019
1 parent 4df92e6 commit 6225b9f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 3 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -163,7 +162,9 @@ readdirp.promise(schemaPath, { root: schemaPath, fileFilter: `*.${schemaExtensio
generate,

// generate Markdown ASTs
build({}),
build({
header: argv.h
}),

// build readme
readme({
Expand Down
18 changes: 13 additions & 5 deletions lib/markdownBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit 6225b9f

Please sign in to comment.