mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 16:52:53 +08:00
docs: differentiate between member properties and methods
This commit is contained in:
parent
a5ebfbfc5d
commit
97ad1bc92f
@ -22,6 +22,7 @@ module.exports = function(currentVersion) {
|
|||||||
.processor(require('./processors/jekyll'))
|
.processor(require('./processors/jekyll'))
|
||||||
.processor(require('./processors/remove-private-members'))
|
.processor(require('./processors/remove-private-members'))
|
||||||
.processor(require('./processors/hide-private-api'))
|
.processor(require('./processors/hide-private-api'))
|
||||||
|
.processor(require('./processors/collect-inputs-outputs'))
|
||||||
|
|
||||||
// for debugging docs
|
// for debugging docs
|
||||||
// .processor(function test(){
|
// .processor(function test(){
|
||||||
|
62
scripts/docs/processors/collect-inputs-outputs.js
Normal file
62
scripts/docs/processors/collect-inputs-outputs.js
Normal 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;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
8
scripts/docs/templates/common.template.html
vendored
8
scripts/docs/templates/common.template.html
vendored
@ -56,11 +56,11 @@ docType: "<$ doc.docType $>"
|
|||||||
|
|
||||||
<@- macro functionSyntax(fn) @>
|
<@- macro functionSyntax(fn) @>
|
||||||
<@- set sep = joiner(', ') -@>
|
<@- set sep = joiner(', ') -@>
|
||||||
<code><$ fn.name $>(<@- for param in fn.params @><$ sep() $>
|
<code><$ fn.name $><@- if not fn.isProperty @>(<@ endif -@><@- for param in fn.params @><$ sep() $>
|
||||||
<@- if param.type.optional @>[<@ endif -@>
|
<@- if param.type.optional @>[<@ endif -@>
|
||||||
<$ param.name $>
|
<$ param.name $>
|
||||||
<@- if param.type.optional @>]<@ endif -@>
|
<@- if param.type.optional @>]<@ endif -@>
|
||||||
<@ endfor @>)</code>
|
<@ endfor @><@- if not fn.isProperty @>)<@ endif -@></code>
|
||||||
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
|
<@ if fn.alias @><small>(alias: <$ fn.alias $>)</small><@ endif @>
|
||||||
<@ endmacro -@>
|
<@ endmacro -@>
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ docType: "<$ doc.docType $>"
|
|||||||
<@ endif @>
|
<@ endif @>
|
||||||
|
|
||||||
<@- if doc.statics.length -@>
|
<@- if doc.statics.length -@>
|
||||||
<h2>Static Methods</h2>
|
<h2>Static Members</h2>
|
||||||
<@- for method in doc.statics @><@ if not method.internal @>
|
<@- for method in doc.statics @><@ if not method.internal @>
|
||||||
<div id="<$ method.name $>"></div>
|
<div id="<$ method.name $>"></div>
|
||||||
<h3><$ functionSyntax(method) $></h3>
|
<h3><$ functionSyntax(method) $></h3>
|
||||||
@ -244,7 +244,7 @@ docType: "<$ doc.docType $>"
|
|||||||
<!-- methods on the class -->
|
<!-- methods on the class -->
|
||||||
<@- if doc.members and doc.members.length @>
|
<@- if doc.members and doc.members.length @>
|
||||||
|
|
||||||
<h2>Instance Methods</h2>
|
<h2>Instance Members</h2>
|
||||||
<@- for method in doc.members @>
|
<@- for method in doc.members @>
|
||||||
|
|
||||||
<div id="<$ method.name $>"></div>
|
<div id="<$ method.name $>"></div>
|
||||||
|
Loading…
Reference in New Issue
Block a user