Skip to content

Commit

Permalink
add examples to the description
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Aug 8, 2018
1 parent b4f1126 commit 71b3a49
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,23 @@ const highlight = false;

Handlebars.registerHelper('desc', function(schema) {
var description = schema.description;
var examples = schema.examples;

var text = "";

if( !description && !examples ) {
return "";
}

if ( description ) {
text = description
}

if ( examples && examples.length > 0 ) {
examples = [ " Examples: \n" ].concat(examples).join("\n\t");
text = text + examples;
}

if( !description ) return "";
var text = description;
if(marked) {
marked.setOptions({gfm: true, breaks: true})
return new Handlebars.SafeString(marked(text));
Expand Down

0 comments on commit 71b3a49

Please sign in to comment.