chore(dgeni): setting inputs and outputs detection in dgeni

This commit is contained in:
perry
2016-02-09 19:02:11 -06:00
committed by mhartington
parent e6068785f6
commit 19ecc7a3af
4 changed files with 115 additions and 24 deletions

View File

@ -20,6 +20,7 @@ module.exports = function(currentVersion){
.processor(require('./processors/jekyll'))
.processor(require('./processors/remove-private-members'))
.processor(require('./processors/hide-private-api'))
.processor(require('./processors/collect-inputs-outputs'))
// for debugging docs
@ -29,7 +30,8 @@ module.exports = function(currentVersion){
// $runBefore: ['rendering-docs'],
// $process: function(docs){
// docs.forEach(function(doc){
// if (doc.members && doc.name == "IonicApp"){
// if (doc.name == "Searchbar"){
// console.log(doc.input);
// doc.members.forEach(function(method){
// if (method.name === "load") {
// console.log(method);
@ -173,4 +175,3 @@ module.exports = function(currentVersion){
})
}

View File

@ -0,0 +1,62 @@
module.exports = function collectInputsOutputs() {
return {
$runBefore: ['rendering-docs'],
$process: function(docs) {
docs.forEach(function(doc) {
// if (doc.members && doc.name == "Searchbar"){
// console.log(doc.exportSymbol.members.hideCancelButton.valueDeclaration.decorators[0].expression.expression);
// doc.members.forEach(function(method){
// if (method.name === "load") {
// console.log(method);
// }
// })
// }
if (doc.members && doc.members.length) {
var members = [];
var inputs = [];
var outputs = [];
memberLoop:
for (var i in doc.members) {
if (doc.members[i].decorators && doc.members[i].decorators.length) {
decoratorLoop:
for (var ii in doc.members[i].decorators) {
if (doc.members[i].decorators[ii].name == 'Input') {
inputs.push(parseMember(doc.members[i]));
continue memberLoop;
}
if (doc.members[i].decorators[ii].name == 'Output') {
outputs.push(parseMember(doc.members[i]));
continue memberLoop;
}
}
// not an input or output, must be a plain member
members.push(doc.members[i]);
};
}
// update doc with pruned members list and add inputs and outputs
doc.members = members;
doc.inputs = inputs;
doc.outputs = outputs;
}
function parseMember(member) {
member.type = member.content.substring(
member.content.indexOf('{') + 1,
member.content.indexOf('}')
);
member.description = member.content.substring(
member.content.indexOf('}') + 1,
member.content.length
);
return member;
}
});
}
};
};

View File

@ -57,6 +57,26 @@ angular_controller: APIDemoCtrl <@ endif @>
</table>
<@- endmacro -@>
<@ macro inputTable(params, isDirective) -@>
<table class="table param-table" style="margin:0;">
<thead>
<tr>
<th>Attr</th>
<th>Type</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<@ for param in params @>
<tr>
<td><$ param.name $></td>
<td><code><$ param.type $></code></td>
<td><$ param.description | marked $></td>
</tr>
<@ endfor @>
</tbody>
</table>
<@- endmacro -@>
<@- macro functionSyntax(fn) @>
<@- set sep = joiner(',&nbsp;') -@>
@ -244,6 +264,20 @@ Improve this doc
<@- endif -@>
<@- if doc.inputs and doc.inputs.length @>
<!-- input methods on the class -->
<h2>Element Input Attributes</h2>
<$ inputTable(doc.inputs) $>
<@- endif -@>
<@- if doc.inputs and doc.inputs.length @>
<!-- output events on the class -->
<h2>Element Output Attributes</h2>
<$ inputTable(doc.outputs) $>
<@- endif -@>
<!-- related link -->
<@- if doc.see @>