chore(docs): parse optional

This commit is contained in:
Ibby 2017-03-23 15:59:33 -04:00
parent 072fe8df94
commit 87916aec20
3 changed files with 28 additions and 7 deletions

View File

@ -16,11 +16,12 @@ module.exports = function(currentVersion) {
return new Package('ionic-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage])
// .processor(require('./processors/latest-version'))
.processor(require('./processors/jekyll'))
.processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api'))
.processor(require('./processors/collect-inputs-outputs'))
.processor(require('./processors/npm-id'))
.processor(require('./processors/jekyll'))
.processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api'))
.processor(require('./processors/collect-inputs-outputs'))
.processor(require('./processors/npm-id'))
.processor(require('./processors/parse-optional'))
// for debugging docs
// .processor(function test(){

View File

@ -0,0 +1,21 @@
module.exports = function parseOptional() {
return {
$runBefore: ['rendering-docs'],
$process: function(docs) {
docs.forEach(function(doc) {
if(doc.members && doc.members.length) {
for (var i in doc.members) {
if(doc.members[i].params && doc.members[i].params.length) {
for (var ii in doc.members[i].params) {
if(doc.members[i].params[ii].optional){
doc.members[i].params[ii].description += '<strong class="tag">Optional</strong>';
}
}
}
}
}
});
return docs;
}
}
};

View File

@ -33,7 +33,7 @@ docType: "<$ doc.docType $>"
</td>
<td>
<$ param.description | marked $>
<@ if param.optional @><strong class="tag">Optional</strong><@ endif @>
<@ if param.optional @><em>(optional)</em><@ endif @>
</td>
</tr>
<@ endfor @>
@ -77,7 +77,6 @@ docType: "<$ doc.docType $>"
</td>
<td>
<$ param.description | marked $>
<@ if param.optional @><strong class="tag">Optional</strong><@ endif @>
<@ if param.defaultValue @><p><em>(default: <$ param.defaultValue $>)</em></p><@ endif @>
</td>
</tr>