mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
adding static methods to dgeni
This commit is contained in:
parent
bd6739d782
commit
c8069b96e5
30
scripts/docs/templates/common.template.html
vendored
30
scripts/docs/templates/common.template.html
vendored
@ -178,10 +178,38 @@ Improve this doc
|
||||
</table>
|
||||
<@ endif @>
|
||||
|
||||
<@- if doc.statics.length -@>
|
||||
<h2>Static Methods</h2>
|
||||
<@- for method in doc.statics @><@ if not method.internal @>
|
||||
<div id="<$ method.name $>"></div>
|
||||
<h3><$ functionSyntax(method) $></h3>
|
||||
|
||||
<$ method.description $>
|
||||
|
||||
<@ if method.params @>
|
||||
<$ paramTable(method.params) $>
|
||||
<@ endif @>
|
||||
|
||||
<@ if method.this @>
|
||||
<h4> Method's `this`
|
||||
<$ method.this $>
|
||||
</h4>
|
||||
<@ endif @>
|
||||
|
||||
<@ if method.returns @>
|
||||
<div class="return-value">
|
||||
<i class="icon ion-arrow-return-left"></i>
|
||||
<b>Returns:</b> <$ typeInfo(method.returns) $>
|
||||
</div>
|
||||
<@ endif @>
|
||||
<@ endif @>
|
||||
<@ endfor -@>
|
||||
<@ endif @>
|
||||
|
||||
<!-- methods on the class -->
|
||||
<@- if doc.members and doc.members.length @>
|
||||
|
||||
<h2>Methods</h2>
|
||||
<h2>Instance Methods</h2>
|
||||
<@- for method in doc.members @>
|
||||
|
||||
<div id="<$ method.name $>"></div>
|
||||
|
@ -12,6 +12,7 @@ module.exports = new Package('typescript-parsing', [basePackage])
|
||||
.factory(require('./services/tsParser/getFileInfo'))
|
||||
.factory(require('./services/tsParser/getExportDocType'))
|
||||
.factory(require('./services/tsParser/getContent'))
|
||||
.factory(require('./services/tsParser/getDirectiveInfo'))
|
||||
|
||||
.factory(require('./services/convertPrivateClassesToInterfaces'))
|
||||
|
||||
|
@ -4,7 +4,9 @@ var _ = require('lodash');
|
||||
var ts = require('typescript');
|
||||
|
||||
module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||
getExportDocType, getContent, createDocMessage, log) {
|
||||
getDirectiveInfo,
|
||||
getExportDocType, getContent,
|
||||
createDocMessage, log) {
|
||||
|
||||
return {
|
||||
$runAfter: ['files-read'],
|
||||
@ -132,8 +134,12 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||
if (a.name < b.name) return -1;
|
||||
return 0;
|
||||
});
|
||||
exportDoc.statics.sort(function(a, b) {
|
||||
if (a.name > b.name) return 1;
|
||||
if (a.name < b.name) return -1;
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -212,7 +218,8 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||
moduleDoc: moduleDoc,
|
||||
content: getContent(exportSymbol),
|
||||
fileInfo: getFileInfo(exportSymbol, basePath),
|
||||
location: getLocation(exportSymbol)
|
||||
location: getLocation(exportSymbol),
|
||||
directiveInfo: getDirectiveInfo(exportSymbol)
|
||||
};
|
||||
|
||||
if (exportDoc.docType === 'var' || exportDoc.docType === 'const' || exportDoc.docType === 'let') {
|
||||
|
@ -57,7 +57,7 @@ module.exports = function createCompilerHost(log) {
|
||||
getNewLine: function() {
|
||||
return ts.sys.newLine;
|
||||
},
|
||||
fileExists: function (fileName) {
|
||||
fileExists: function(fileName) {
|
||||
var text, resolvedPath, resolvedPathWithExt;
|
||||
|
||||
// Strip off the extension and resolve relative to the baseDir
|
||||
|
@ -0,0 +1,34 @@
|
||||
|
||||
module.exports = function getDirectiveInfo() {
|
||||
|
||||
return function (symbol) {
|
||||
var directiveInfo;
|
||||
if (symbol.valueDeclaration) {
|
||||
var decorators = symbol.valueDeclaration.decorators;
|
||||
decorators && decorators.forEach(function(decorator){
|
||||
try {
|
||||
var expr = decorator.expression;
|
||||
var type = expr.expression.text.match(/Component|Directive/);
|
||||
if (type) {
|
||||
// type is either Component or Directive
|
||||
// properties are selector, inputs and outputs
|
||||
directiveInfo = { type: type[0], properties: [] };
|
||||
|
||||
//Directive only takes one argument
|
||||
expr.arguments[0].properties.forEach(function(prop){
|
||||
var name = prop.name.text;
|
||||
if (name === "selector") {
|
||||
directiveInfo.properties.push({name: name, values: prop.initializer.text.split(",")});
|
||||
}
|
||||
if (name === "inputs" || name === "outputs") {
|
||||
var values = prop.initializer.elements.map(function(e){ return e.text });
|
||||
directiveInfo.properties.push({name: name, values: values });
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch(e){}
|
||||
});
|
||||
}
|
||||
return directiveInfo;
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user