docs: differentiate between member properties and methods

This commit is contained in:
perry 2016-06-10 11:30:58 -05:00
parent a5ebfbfc5d
commit 97ad1bc92f
3 changed files with 69 additions and 6 deletions

View File

@ -22,6 +22,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
// .processor(function test(){

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.members.length) {
var members = [];
var inputs = [];
var outputs = [];
memberLoop:
for (var i in doc.members) {
// identify properties to differentiate from methods
if (typeof doc.members[i].parameters == 'undefined') {
doc.members[i].isProperty = true;
}
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]);
} else {
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

@ -55,13 +55,13 @@ docType: "<$ doc.docType $>"
<@- macro functionSyntax(fn) @>
<@- set sep = joiner(',&nbsp;') -@>
<code><$ fn.name $>(<@- for param in fn.params @><$ sep() $>
<@- set sep = joiner(',&nbsp;') -@>
<code><$ fn.name $><@- if not fn.isProperty @>(<@ endif -@><@- for param in fn.params @><$ sep() $>
<@- if param.type.optional @>[<@ endif -@>
<$ param.name $>
<@- if param.type.optional @>]<@ endif -@>
<@ endfor @>)</code>
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
<@ endfor @><@- if not fn.isProperty @>)<@ endif -@></code>
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
<@ endmacro -@>
<@ macro typeList(types) -@>
@ -203,7 +203,7 @@ docType: "<$ doc.docType $>"
<@ endif @>
<@- if doc.statics.length -@>
<h2>Static Methods</h2>
<h2>Static Members</h2>
<@- for method in doc.statics @><@ if not method.internal @>
<div id="<$ method.name $>"></div>
<h3><$ functionSyntax(method) $></h3>
@ -244,7 +244,7 @@ docType: "<$ doc.docType $>"
<!-- methods on the class -->
<@- if doc.members and doc.members.length @>
<h2>Instance Methods</h2>
<h2>Instance Members</h2>
<@- for method in doc.members @>
<div id="<$ method.name $>"></div>