From 97ad1bc92faf14179029e68f80224b4d5ff101f6 Mon Sep 17 00:00:00 2001 From: perry Date: Fri, 10 Jun 2016 11:30:58 -0500 Subject: [PATCH] docs: differentiate between member properties and methods --- scripts/docs/dgeni-config.js | 1 + .../docs/processors/collect-inputs-outputs.js | 62 +++++++++++++++++++ scripts/docs/templates/common.template.html | 12 ++-- 3 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 scripts/docs/processors/collect-inputs-outputs.js diff --git a/scripts/docs/dgeni-config.js b/scripts/docs/dgeni-config.js index 2281a052a..a0cf4217c 100644 --- a/scripts/docs/dgeni-config.js +++ b/scripts/docs/dgeni-config.js @@ -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(){ diff --git a/scripts/docs/processors/collect-inputs-outputs.js b/scripts/docs/processors/collect-inputs-outputs.js new file mode 100644 index 000000000..c8b382e65 --- /dev/null +++ b/scripts/docs/processors/collect-inputs-outputs.js @@ -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; + } + }); + } + }; +}; diff --git a/scripts/docs/templates/common.template.html b/scripts/docs/templates/common.template.html index 4354f8c1d..886f84874 100644 --- a/scripts/docs/templates/common.template.html +++ b/scripts/docs/templates/common.template.html @@ -55,13 +55,13 @@ docType: "<$ doc.docType $>" <@- macro functionSyntax(fn) @> -<@- set sep = joiner(', ') -@> -<$ fn.name $>(<@- for param in fn.params @><$ sep() $> + <@- set sep = joiner(', ') -@> + <$ 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 @>) -<@ if fn.alias @>(alias: <$ fn.alias $>)<@ endif @> + <@ endfor @><@- if not fn.isProperty @>)<@ endif -@> + <@ if fn.alias @>(alias: <$ fn.alias $>)<@ endif @> <@ endmacro -@> <@ macro typeList(types) -@> @@ -203,7 +203,7 @@ docType: "<$ doc.docType $>" <@ endif @> <@- if doc.statics.length -@> -

Static Methods

+

Static Members

<@- for method in doc.statics @><@ if not method.internal @>

<$ functionSyntax(method) $>

@@ -244,7 +244,7 @@ docType: "<$ doc.docType $>" <@- if doc.members and doc.members.length @> -

Instance Methods

+

Instance Members

<@- for method in doc.members @>