Skip to content

Commit

Permalink
add option to generate summary only
Browse files Browse the repository at this point in the history
  • Loading branch information
krahenbuhl committed Mar 25, 2022
1 parent 798352d commit 80bc43b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
6 changes: 4 additions & 2 deletions bin/wetzel.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ if (!defined(argv._[0]) || defined(argv.h) || defined(argv.help)) {
' artifacts useful in debugging wetzel.\n' +
' -w, --suppressWarnings Will not print out WETZEL_WARNING strings indicating identified\n' +
' conversion problems. Default: false\n' +
' -z, --detailedSummary Adds more details in the summary table. Default: false\n'
' --detailedSummary Adds more details in the summary table. Default: false\n' +
' --summary Only write the summary and skip the detailed section, useful for a more concise documentation. Default: false\n'
process.stdout.write(help);
return;
}
Expand Down Expand Up @@ -82,7 +83,8 @@ var options = {
suppressWarnings: defaultValue(defaultValue(argv.w, argv.suppressWarnings), false),
autoLink: autoLink,
ignorableTypes: ignorableTypes,
detailedSummary: defaultValue(defaultValue(argv.z, argv.detailedSummary), false),
detailedSummary: defaultValue(argv.detailedSummary, false),
summaryOnly: defaultValue(argv.summary, false)
};

if (defined(embedOutput)) {
Expand Down
27 changes: 17 additions & 10 deletions lib/generateMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function generateMarkdown(options) {
orderedTypesDescending,
options.autoLink,
options.embedMode,
options.summaryOnly,
options.detailedSummary);
}

Expand Down Expand Up @@ -155,7 +156,7 @@ function getRecursiveTOC(orderedTypes, parentTitle, depth) {
* @param {string} embedMode Emum value indicating if we are embedding JSON schema include directives.
* @return {string} The markdown for the schema.
*/
function getSchemaMarkdown(schema, fileName, headerLevel, suppressWarnings, schemaRelativeBasePath, knownTypes, autoLink, embedMode, detailedSummary) {
function getSchemaMarkdown(schema, fileName, headerLevel, suppressWarnings, schemaRelativeBasePath, knownTypes, autoLink, embedMode, summaryOnly, detailedSummary) {
var md = '';

if (schema === undefined) {
Expand Down Expand Up @@ -200,12 +201,15 @@ function getSchemaMarkdown(schema, fileName, headerLevel, suppressWarnings, sche
// Render table with summary of each property
md += createPropertiesSummary(schema, knownTypes, autoLink, detailedSummary);

value = schema.additionalProperties;
if (defined(value) && !value) {
md += 'Additional properties are not allowed.\n\n';
} else {
md += 'Additional properties are allowed.\n\n';
// TODO: display their schema
if (!summaryOnly)
{
value = schema.additionalProperties;
if (defined(value) && !value) {
md += 'Additional properties are not allowed.\n\n';
} else {
md += 'Additional properties are allowed.\n\n';
// TODO: display their schema
}
}

// Schema reference
Expand All @@ -219,9 +223,12 @@ function getSchemaMarkdown(schema, fileName, headerLevel, suppressWarnings, sche
}

// Render section for each property
var title = defaultValue(schema.title, suppressWarnings ? '' : 'WETZEL_WARNING: title not defined');
md += createPropertiesDetails(schema, title, headerLevel + 1, knownTypes, autoLink);
md += createExamples(schema, headerLevel);
if (!summaryOnly)
{
var title = defaultValue(schema.title, suppressWarnings ? '' : 'WETZEL_WARNING: title not defined');
md += createPropertiesDetails(schema, title, headerLevel + 1, knownTypes, autoLink);
md += createExamples(schema, headerLevel);
}
}

return md;
Expand Down

0 comments on commit 80bc43b

Please sign in to comment.