mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-28 22:10:20 +08:00
updating CI to specify ruby version and upgrading typescript doc parsing engine
This commit is contained in:
parent
20b2f3f304
commit
536a8e5898
@ -1,7 +1,8 @@
|
|||||||
machine:
|
machine:
|
||||||
node:
|
node:
|
||||||
version: 4.1.0
|
version: 4.1.0
|
||||||
|
ruby:
|
||||||
|
version: 2.1.2
|
||||||
test:
|
test:
|
||||||
override:
|
override:
|
||||||
- echo "Skipping tests for now"
|
- echo "Skipping tests for now"
|
||||||
|
3
dist/src/plugins/touchid.js
vendored
3
dist/src/plugins/touchid.js
vendored
@ -1,3 +1,4 @@
|
|||||||
|
"use strict";
|
||||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||||
@ -50,6 +51,6 @@ var TouchID = (function () {
|
|||||||
__metadata('design:paramtypes', [])
|
__metadata('design:paramtypes', [])
|
||||||
], TouchID);
|
], TouchID);
|
||||||
return TouchID;
|
return TouchID;
|
||||||
})();
|
}());
|
||||||
exports.TouchID = TouchID;
|
exports.TouchID = TouchID;
|
||||||
//# sourceMappingURL=touchid.js.map
|
//# sourceMappingURL=touchid.js.map
|
2
dist/src/plugins/touchid.js.map
vendored
2
dist/src/plugins/touchid.js.map
vendored
@ -1 +1 @@
|
|||||||
{"version":3,"file":"touchid.js","sourceRoot":"","sources":["../../../src/plugins/touchid.ts"],"names":["TouchID","TouchID.constructor","TouchID.isAvailable","TouchID.verifyFingerprint","TouchID.verifyFingerprintWithCustomPasswordFallback","TouchID.verifyFingerprintWithCustomPasswordFallbackAndEnterPasswordLabel"],"mappings":";;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;IAAAA;IAkBAC,CAACA;IAVCD,6BAAWA,GADXA,cACeE,CAACA;;IAGTF,yBAAiBA,GADxBA,UACyBA,OAAcA,IAAGG,CAACA;IAGpCH,mDAA2CA,GADlDA,UACmDA,OAAcA,IAAGI,CAACA;IAG9DJ,wEAAgEA,GADvEA,UACwEA,OAAcA,EAAEA,kBAAyBA,IAAGK,CAACA;IAVrHL;QAACA,gBAAOA,EAAEA;;;;OACVA,gCAAWA,QAAKA;IAEhBA;QAACA,gBAAOA,EAAEA;;;;OACHA,4BAAiBA,QAAmBA;IAE3CA;QAACA,gBAAOA,EAAEA;;;;OACHA,sDAA2CA,QAAmBA;IAErEA;QAACA,gBAAOA,EAAEA;;;;OACHA,2EAAgEA,QAA8CA;IAjBvHA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,SAASA;YACfA,MAAMA,EAAEA,yBAAyBA;YACjCA,SAASA,EAAEA,iBAAiBA;YAC5BA,IAAIA,EAAEA,2DAA2DA;SAClEA,CAACA;;gBAaDA;IAADA,cAACA;AAADA,CAACA,AAlBD,IAkBC;AAZY,eAAO,UAYnB,CAAA"}
|
{"version":3,"file":"touchid.js","sourceRoot":"","sources":["../../../src/plugins/touchid.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAQzC;IAAA;IAYA,CAAC;IAVQ,6BAAW,GAAlB,cAAsB,CAAC;;IAGhB,yBAAiB,GAAxB,UAAyB,OAAc,IAAG,CAAC;IAGpC,mDAA2C,GAAlD,UAAmD,OAAc,IAAG,CAAC;IAG9D,wEAAgE,GAAvE,UAAwE,OAAc,EAAE,kBAAyB,IAAG,CAAC;IAVrH;QAAC,gBAAO,EAAE;;;;8CAAA;IAGV;QAAC,gBAAO,EAAE;;;;0CAAA;IAGV;QAAC,gBAAO,EAAE;;;;oEAAA;IAGV;QAAC,gBAAO,EAAE;;;;yFAAA;IAhBZ;QAAC,eAAM,CAAC;YACN,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,yBAAyB;YACjC,SAAS,EAAE,iBAAiB;YAC5B,IAAI,EAAE,2DAA2D;SAClE,CAAC;;eAAA;IAaF,cAAC;AAAD,CAAC,AAZD,IAYC;AAZY,eAAO,UAYnB,CAAA"}
|
14
scripts/docs/typescript-package/index.js
Normal file → Executable file
14
scripts/docs/typescript-package/index.js
Normal file → Executable file
@ -1,5 +1,3 @@
|
|||||||
//require('../../tools/transpiler/index.js').init();
|
|
||||||
|
|
||||||
var basePackage = require('dgeni-packages/base');
|
var basePackage = require('dgeni-packages/base');
|
||||||
var Package = require('dgeni').Package;
|
var Package = require('dgeni').Package;
|
||||||
var path = require('canonical-path');
|
var path = require('canonical-path');
|
||||||
@ -14,7 +12,8 @@ module.exports = new Package('typescript-parsing', [basePackage])
|
|||||||
.factory(require('./services/tsParser/getFileInfo'))
|
.factory(require('./services/tsParser/getFileInfo'))
|
||||||
.factory(require('./services/tsParser/getExportDocType'))
|
.factory(require('./services/tsParser/getExportDocType'))
|
||||||
.factory(require('./services/tsParser/getContent'))
|
.factory(require('./services/tsParser/getContent'))
|
||||||
.factory(require('./services/tsParser/getDirectiveInfo'))
|
|
||||||
|
.factory(require('./services/convertPrivateClassesToInterfaces'))
|
||||||
|
|
||||||
.factory('EXPORT_DOC_TYPES', function() {
|
.factory('EXPORT_DOC_TYPES', function() {
|
||||||
return [
|
return [
|
||||||
@ -23,6 +22,7 @@ module.exports = new Package('typescript-parsing', [basePackage])
|
|||||||
'function',
|
'function',
|
||||||
'var',
|
'var',
|
||||||
'const',
|
'const',
|
||||||
|
'let',
|
||||||
'enum',
|
'enum',
|
||||||
'type-alias'
|
'type-alias'
|
||||||
];
|
];
|
||||||
@ -45,16 +45,18 @@ module.exports = new Package('typescript-parsing', [basePackage])
|
|||||||
computeIdsProcessor.idTemplates.push({
|
computeIdsProcessor.idTemplates.push({
|
||||||
docTypes: ['member'],
|
docTypes: ['member'],
|
||||||
idTemplate: '${classDoc.id}.${name}',
|
idTemplate: '${classDoc.id}.${name}',
|
||||||
getAliases: function(doc) { return [doc.id]; }
|
getAliases: function(doc) {
|
||||||
|
return doc.classDoc.aliases.map(function(alias) { return alias + '.' + doc.name; });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
computePathsProcessor.pathTemplates.push({
|
computePathsProcessor.pathTemplates.push({
|
||||||
docTypes: ['member'],
|
docTypes: ['member'],
|
||||||
pathTemplate: '${classDoc.path}/${name}',
|
pathTemplate: '${classDoc.path}#${name}',
|
||||||
getOutputPath: function() {} // These docs are not written to their own file, instead they are part of their class doc
|
getOutputPath: function() {} // These docs are not written to their own file, instead they are part of their class doc
|
||||||
});
|
});
|
||||||
|
|
||||||
var MODULES_DOCS_PATH = 'docs';
|
var MODULES_DOCS_PATH = 'partials/modules';
|
||||||
|
|
||||||
computePathsProcessor.pathTemplates.push({
|
computePathsProcessor.pathTemplates.push({
|
||||||
docTypes: ['module'],
|
docTypes: ['module'],
|
||||||
|
0
scripts/docs/typescript-package/mocks/mockPackage.js
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/mockPackage.js
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/readTypeScriptModules/ignoreExportsMatching.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/readTypeScriptModules/ignoreExportsMatching.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/readTypeScriptModules/interfaces.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/readTypeScriptModules/interfaces.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/readTypeScriptModules/orderingOfMembers.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/readTypeScriptModules/orderingOfMembers.ts
Normal file → Executable file
@ -0,0 +1 @@
|
|||||||
|
export var x = 10;
|
@ -0,0 +1,3 @@
|
|||||||
|
export { x as y} from './privateModule';
|
||||||
|
|
||||||
|
export abstract class AbstractClass {}
|
0
scripts/docs/typescript-package/mocks/tsParser/importedSrc.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/tsParser/importedSrc.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/tsParser/testSrc.ts
Normal file → Executable file
0
scripts/docs/typescript-package/mocks/tsParser/testSrc.ts
Normal file → Executable file
143
scripts/docs/typescript-package/processors/readTypeScriptModules.js
Normal file → Executable file
143
scripts/docs/typescript-package/processors/readTypeScriptModules.js
Normal file → Executable file
@ -4,8 +4,7 @@ var _ = require('lodash');
|
|||||||
var ts = require('typescript');
|
var ts = require('typescript');
|
||||||
|
|
||||||
module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
||||||
getExportDocType, getContent,
|
getExportDocType, getContent, createDocMessage, log) {
|
||||||
getDirectiveInfo, log) {
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
$runAfter: ['files-read'],
|
$runAfter: ['files-read'],
|
||||||
@ -61,13 +60,26 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
|
|
||||||
// If the symbol is an Alias then for most things we want the original resolved symbol
|
// If the symbol is an Alias then for most things we want the original resolved symbol
|
||||||
var resolvedExport = exportSymbol.resolvedSymbol || exportSymbol;
|
var resolvedExport = exportSymbol.resolvedSymbol || exportSymbol;
|
||||||
|
|
||||||
|
// If the resolved symbol contains no declarations then it is invalid
|
||||||
|
// (probably an abstract class)
|
||||||
|
// For the moment we are just going to ignore such exports
|
||||||
|
// TODO: find a way of generating docs for them
|
||||||
|
if (!resolvedExport.declarations) return;
|
||||||
|
|
||||||
var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, parseInfo.typeChecker);
|
var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, parseInfo.typeChecker);
|
||||||
log.debug('>>>> EXPORT: ' + exportDoc.name + ' (' + exportDoc.docType + ') from ' + moduleDoc.id);
|
log.debug('>>>> EXPORT: ' + exportDoc.name + ' (' + exportDoc.docType + ') from ' + moduleDoc.id);
|
||||||
|
|
||||||
|
// Add this export doc to its module doc
|
||||||
|
moduleDoc.exports.push(exportDoc);
|
||||||
|
docs.push(exportDoc);
|
||||||
|
|
||||||
|
exportDoc.members = [];
|
||||||
|
exportDoc.statics = [];
|
||||||
|
|
||||||
// Generate docs for each of the export's members
|
// Generate docs for each of the export's members
|
||||||
if (resolvedExport.flags & ts.SymbolFlags.HasMembers) {
|
if (resolvedExport.flags & ts.SymbolFlags.HasMembers) {
|
||||||
|
|
||||||
exportDoc.members = [];
|
|
||||||
for(var memberName in resolvedExport.members) {
|
for(var memberName in resolvedExport.members) {
|
||||||
// FIXME(alexeagle): why do generic type params appear in members?
|
// FIXME(alexeagle): why do generic type params appear in members?
|
||||||
if (memberName === 'T') {
|
if (memberName === 'T') {
|
||||||
@ -92,6 +104,27 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
exportDoc.newMember = memberDoc;
|
exportDoc.newMember = memberDoc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exportDoc.docType === 'enum') {
|
||||||
|
for(var memberName in resolvedExport.exports) {
|
||||||
|
log.silly('>>>>>> member: ' + memberName + ' from ' + exportDoc.id + ' in ' + moduleDoc.id);
|
||||||
|
var memberSymbol = resolvedExport.exports[memberName];
|
||||||
|
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
|
||||||
|
docs.push(memberDoc);
|
||||||
|
exportDoc.members.push(memberDoc);
|
||||||
|
}
|
||||||
|
} else if (resolvedExport.flags & ts.SymbolFlags.HasExports) {
|
||||||
|
for (var exported in resolvedExport.exports) {
|
||||||
|
if (exported === 'prototype') continue;
|
||||||
|
if (hidePrivateMembers && exported.charAt(0) === '_') continue;
|
||||||
|
var memberSymbol = resolvedExport.exports[exported];
|
||||||
|
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker);
|
||||||
|
memberDoc.isStatic = true;
|
||||||
|
docs.push(memberDoc);
|
||||||
|
exportDoc.statics.push(memberDoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sortClassMembers) {
|
if (sortClassMembers) {
|
||||||
exportDoc.members.sort(function(a, b) {
|
exportDoc.members.sort(function(a, b) {
|
||||||
@ -100,18 +133,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (exportDoc.docType == 'enum') {
|
|
||||||
exportDoc.members = [];
|
|
||||||
for (var etype in resolvedExport.exports) {
|
|
||||||
exportDoc.members.push(etype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this export doc to its module doc
|
|
||||||
moduleDoc.exports.push(exportDoc);
|
|
||||||
docs.push(exportDoc);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -120,10 +142,12 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
|
|
||||||
function createModuleDoc(moduleSymbol, basePath) {
|
function createModuleDoc(moduleSymbol, basePath) {
|
||||||
var id = moduleSymbol.name.replace(/^"|"$/g, '');
|
var id = moduleSymbol.name.replace(/^"|"$/g, '');
|
||||||
|
var name = id.split('/').pop();
|
||||||
var moduleDoc = {
|
var moduleDoc = {
|
||||||
docType: 'module',
|
docType: 'module',
|
||||||
|
name: name,
|
||||||
id: id,
|
id: id,
|
||||||
aliases: [id],
|
aliases: [id, name],
|
||||||
moduleTree: moduleSymbol,
|
moduleTree: moduleSymbol,
|
||||||
content: getContent(moduleSymbol),
|
content: getContent(moduleSymbol),
|
||||||
exports: [],
|
exports: [],
|
||||||
@ -136,6 +160,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
function createExportDoc(name, exportSymbol, moduleDoc, basePath, typeChecker) {
|
function createExportDoc(name, exportSymbol, moduleDoc, basePath, typeChecker) {
|
||||||
var typeParamString = '';
|
var typeParamString = '';
|
||||||
var heritageString = '';
|
var heritageString = '';
|
||||||
|
var typeDefinition = '';
|
||||||
|
|
||||||
exportSymbol.declarations.forEach(function(decl) {
|
exportSymbol.declarations.forEach(function(decl) {
|
||||||
var sourceFile = ts.getSourceFileOfNode(decl);
|
var sourceFile = ts.getSourceFileOfNode(decl);
|
||||||
@ -144,6 +169,10 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
typeParamString = '<' + getText(sourceFile, decl.typeParameters) + '>';
|
typeParamString = '<' + getText(sourceFile, decl.typeParameters) + '>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (decl.symbol.flags & ts.SymbolFlags.TypeAlias) {
|
||||||
|
typeDefinition = getText(sourceFile, decl.type);
|
||||||
|
}
|
||||||
|
|
||||||
if (decl.heritageClauses) {
|
if (decl.heritageClauses) {
|
||||||
decl.heritageClauses.forEach(function(heritage) {
|
decl.heritageClauses.forEach(function(heritage) {
|
||||||
|
|
||||||
@ -173,24 +202,43 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
|
|
||||||
var exportDoc = {
|
var exportDoc = {
|
||||||
docType: getExportDocType(exportSymbol),
|
docType: getExportDocType(exportSymbol),
|
||||||
|
exportSymbol: exportSymbol,
|
||||||
name: name,
|
name: name,
|
||||||
id: moduleDoc.id + '/' + name,
|
id: moduleDoc.id + '/' + name,
|
||||||
typeParams: typeParamString,
|
typeParams: typeParamString,
|
||||||
heritage: heritageString,
|
heritage: heritageString,
|
||||||
|
decorators: getDecorators(exportSymbol),
|
||||||
aliases: aliasNames,
|
aliases: aliasNames,
|
||||||
moduleDoc: moduleDoc,
|
moduleDoc: moduleDoc,
|
||||||
content: getContent(exportSymbol),
|
content: getContent(exportSymbol),
|
||||||
fileInfo: getFileInfo(exportSymbol, basePath),
|
fileInfo: getFileInfo(exportSymbol, basePath),
|
||||||
location: getLocation(exportSymbol),
|
location: getLocation(exportSymbol)
|
||||||
directiveInfo: getDirectiveInfo(exportSymbol)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (exportDoc.docType === 'var' || exportDoc.docType === 'const' || exportDoc.docType === 'let') {
|
||||||
|
exportDoc.symbolTypeName = exportSymbol.valueDeclaration.type &&
|
||||||
|
exportSymbol.valueDeclaration.type.typeName &&
|
||||||
|
exportSymbol.valueDeclaration.type.typeName.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exportDoc.docType === 'type-alias') {
|
||||||
|
exportDoc.returnType = getReturnType(typeChecker, exportSymbol);
|
||||||
|
}
|
||||||
|
|
||||||
if(exportSymbol.flags & ts.SymbolFlags.Function) {
|
if(exportSymbol.flags & ts.SymbolFlags.Function) {
|
||||||
exportDoc.parameters = getParameters(typeChecker, exportSymbol);
|
exportDoc.parameters = getParameters(typeChecker, exportSymbol);
|
||||||
}
|
}
|
||||||
if(exportSymbol.flags & ts.SymbolFlags.Value) {
|
if(exportSymbol.flags & ts.SymbolFlags.Value) {
|
||||||
exportDoc.returnType = getReturnType(typeChecker, exportSymbol);
|
exportDoc.returnType = getReturnType(typeChecker, exportSymbol);
|
||||||
}
|
}
|
||||||
|
if (exportSymbol.flags & ts.SymbolFlags.TypeAlias) {
|
||||||
|
exportDoc.typeDefinition = typeDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute the original module name from the relative file path
|
||||||
|
exportDoc.originalModule = exportDoc.fileInfo.relativePath
|
||||||
|
.replace(new RegExp('\.' + exportDoc.fileInfo.extension + '$'), '');
|
||||||
|
|
||||||
return exportDoc;
|
return exportDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,6 +247,7 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
docType: 'member',
|
docType: 'member',
|
||||||
classDoc: classDoc,
|
classDoc: classDoc,
|
||||||
name: memberSymbol.name,
|
name: memberSymbol.name,
|
||||||
|
decorators: getDecorators(memberSymbol),
|
||||||
content: getContent(memberSymbol),
|
content: getContent(memberSymbol),
|
||||||
fileInfo: getFileInfo(memberSymbol, basePath),
|
fileInfo: getFileInfo(memberSymbol, basePath),
|
||||||
location: getLocation(memberSymbol)
|
location: getLocation(memberSymbol)
|
||||||
@ -242,6 +291,45 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
return memberDoc;
|
return memberDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getDecorators(symbol) {
|
||||||
|
|
||||||
|
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||||
|
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||||
|
|
||||||
|
var decorators = declaration.decorators && declaration.decorators.map(function(decorator) {
|
||||||
|
decorator = decorator.expression;
|
||||||
|
return {
|
||||||
|
name: decorator.expression ? decorator.expression.text : decorator.text,
|
||||||
|
arguments: decorator.arguments && decorator.arguments.map(function(argument) {
|
||||||
|
return getText(sourceFile, argument).trim();
|
||||||
|
}),
|
||||||
|
argumentInfo: decorator.arguments && decorator.arguments.map(function(argument) {
|
||||||
|
return parseArgument(argument);
|
||||||
|
}),
|
||||||
|
expression: decorator
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return decorators;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseProperties(properties) {
|
||||||
|
var result = {};
|
||||||
|
_.forEach(properties, function(property) {
|
||||||
|
result[property.name.text] = parseArgument(property.initializer);
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseArgument(argument) {
|
||||||
|
if (argument.text) return argument.text;
|
||||||
|
if (argument.properties) return parseProperties(argument.properties);
|
||||||
|
if (argument.elements) return argument.elements.map(function(element) { return element.text; });
|
||||||
|
var sourceFile = ts.getSourceFileOfNode(argument);
|
||||||
|
var text = getText(sourceFile, argument).trim();
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
function getParameters(typeChecker, symbol) {
|
function getParameters(typeChecker, symbol) {
|
||||||
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
var declaration = symbol.valueDeclaration || symbol.declarations[0];
|
||||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||||
@ -252,7 +340,11 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
' at line ' + location.start.line);
|
' at line ' + location.start.line);
|
||||||
}
|
}
|
||||||
return declaration.parameters.map(function(parameter) {
|
return declaration.parameters.map(function(parameter) {
|
||||||
var paramText = getText(sourceFile, parameter.name);
|
var paramText = '';
|
||||||
|
if (parameter.dotDotDotToken) {
|
||||||
|
paramText += '...';
|
||||||
|
}
|
||||||
|
paramText += getText(sourceFile, parameter.name);
|
||||||
if (parameter.questionToken || parameter.initializer) {
|
if (parameter.questionToken || parameter.initializer) {
|
||||||
paramText += '?';
|
paramText += '?';
|
||||||
}
|
}
|
||||||
@ -260,6 +352,9 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
paramText += ':' + getType(sourceFile, parameter.type);
|
paramText += ':' + getType(sourceFile, parameter.type);
|
||||||
} else {
|
} else {
|
||||||
paramText += ': any';
|
paramText += ': any';
|
||||||
|
if (parameter.dotDotDotToken) {
|
||||||
|
paramText += '[]';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return paramText.trim();
|
return paramText.trim();
|
||||||
});
|
});
|
||||||
@ -280,6 +375,14 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
var sourceFile = ts.getSourceFileOfNode(declaration);
|
var sourceFile = ts.getSourceFileOfNode(declaration);
|
||||||
if (declaration.type) {
|
if (declaration.type) {
|
||||||
return getType(sourceFile, declaration.type).trim();
|
return getType(sourceFile, declaration.type).trim();
|
||||||
|
} else if (declaration.initializer) {
|
||||||
|
// The symbol does not have a "type" but it is being initialized
|
||||||
|
// so we can deduce the type of from the initializer (mostly).
|
||||||
|
if (declaration.initializer.expression) {
|
||||||
|
return declaration.initializer.expression.text.trim();
|
||||||
|
} else {
|
||||||
|
return getType(sourceFile, declaration.initializer).trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,8 +405,8 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
|
|||||||
function getType(sourceFile, type) {
|
function getType(sourceFile, type) {
|
||||||
var text = getText(sourceFile, type);
|
var text = getText(sourceFile, type);
|
||||||
while (text.indexOf(".") >= 0) {
|
while (text.indexOf(".") >= 0) {
|
||||||
// Keep namespaced symbols in Rx
|
// Keep namespaced symbols in RxNext
|
||||||
if (text.match(/^\s*Rx\./)) break;
|
if (text.match(/^\s*RxNext\./)) break;
|
||||||
// handle the case List<thing.stuff> -> List<stuff>
|
// handle the case List<thing.stuff> -> List<stuff>
|
||||||
text = text.replace(/([^.<]*)\.([^>]*)/, "$2");
|
text = text.replace(/([^.<]*)\.([^>]*)/, "$2");
|
||||||
}
|
}
|
||||||
|
21
scripts/docs/typescript-package/processors/readTypeScriptModules.spec.js
Normal file → Executable file
21
scripts/docs/typescript-package/processors/readTypeScriptModules.spec.js
Normal file → Executable file
@ -13,6 +13,27 @@ describe('readTypeScriptModules', function() {
|
|||||||
processor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
|
processor.basePath = path.resolve(__dirname, '../mocks/readTypeScriptModules');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('exportDocs', function() {
|
||||||
|
it('should provide the original module if the export is re-exported', function() {
|
||||||
|
processor.sourceFiles = [ 'publicModule.ts' ];
|
||||||
|
var docs = [];
|
||||||
|
processor.$process(docs);
|
||||||
|
|
||||||
|
var exportedDoc = docs[1];
|
||||||
|
expect(exportedDoc.originalModule).toEqual('privateModule');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should include exported abstract classes', function() {
|
||||||
|
processor.sourceFiles = [ 'publicModule.ts' ];
|
||||||
|
var docs = [];
|
||||||
|
processor.$process(docs);
|
||||||
|
|
||||||
|
var exportedDoc = docs[2];
|
||||||
|
expect(exportedDoc.name).toEqual('AbstractClass');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('ignoreExportsMatching', function() {
|
describe('ignoreExportsMatching', function() {
|
||||||
it('should ignore exports that match items in the `ignoreExportsMatching` property', function() {
|
it('should ignore exports that match items in the `ignoreExportsMatching` property', function() {
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
|
module.exports = function convertPrivateClassesToInterfaces() {
|
||||||
|
return function(exportDocs, addInjectableReference) {
|
||||||
|
_.forEach(exportDocs, function(exportDoc) {
|
||||||
|
|
||||||
|
// Search for classes with a constructor marked as `@internal`
|
||||||
|
if (exportDoc.docType === 'class' && exportDoc.constructorDoc && exportDoc.constructorDoc.internal) {
|
||||||
|
|
||||||
|
// Convert this class to an interface with no constructor
|
||||||
|
exportDoc.docType = 'interface';
|
||||||
|
exportDoc.constructorDoc = null;
|
||||||
|
|
||||||
|
if (exportDoc.heritage) {
|
||||||
|
// convert the heritage since interfaces use `extends` not `implements`
|
||||||
|
exportDoc.heritage = exportDoc.heritage.replace('implements', 'extends');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addInjectableReference) {
|
||||||
|
// Add the `declare var SomeClass extends InjectableReference` construct
|
||||||
|
exportDocs.push({
|
||||||
|
docType: 'var',
|
||||||
|
name: exportDoc.name,
|
||||||
|
id: exportDoc.id,
|
||||||
|
returnType: 'InjectableReference'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
@ -0,0 +1,76 @@
|
|||||||
|
var mockPackage = require('../mocks/mockPackage');
|
||||||
|
var Dgeni = require('dgeni');
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
|
describe('readTypeScriptModules', function() {
|
||||||
|
var dgeni, injector, convertPrivateClassesToInterfaces;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
dgeni = new Dgeni([mockPackage()]);
|
||||||
|
injector = dgeni.configureInjector();
|
||||||
|
convertPrivateClassesToInterfaces = injector.get('convertPrivateClassesToInterfaces');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should convert private class docs to interface docs', function() {
|
||||||
|
var docs = [
|
||||||
|
{
|
||||||
|
docType: 'class',
|
||||||
|
name: 'privateClass',
|
||||||
|
id: 'privateClass',
|
||||||
|
constructorDoc: { internal: true }
|
||||||
|
}
|
||||||
|
];
|
||||||
|
convertPrivateClassesToInterfaces(docs, false);
|
||||||
|
expect(docs[0].docType).toEqual('interface');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should not touch non-private class docs', function() {
|
||||||
|
var docs = [
|
||||||
|
{
|
||||||
|
docType: 'class',
|
||||||
|
name: 'privateClass',
|
||||||
|
id: 'privateClass',
|
||||||
|
constructorDoc: { }
|
||||||
|
}
|
||||||
|
];
|
||||||
|
convertPrivateClassesToInterfaces(docs, false);
|
||||||
|
expect(docs[0].docType).toEqual('class');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should convert the heritage since interfaces use `extends` not `implements`', function() {
|
||||||
|
var docs = [
|
||||||
|
{
|
||||||
|
docType: 'class',
|
||||||
|
name: 'privateClass',
|
||||||
|
id: 'privateClass',
|
||||||
|
constructorDoc: { internal: true },
|
||||||
|
heritage: 'implements parentInterface'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
convertPrivateClassesToInterfaces(docs, false);
|
||||||
|
expect(docs[0].heritage).toEqual('extends parentInterface');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should add new injectable reference types, if specified, to the passed in collection', function() {
|
||||||
|
var docs = [
|
||||||
|
{
|
||||||
|
docType: 'class',
|
||||||
|
name: 'privateClass',
|
||||||
|
id: 'privateClass',
|
||||||
|
constructorDoc: { internal: true },
|
||||||
|
heritage: 'implements parentInterface'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
convertPrivateClassesToInterfaces(docs, true);
|
||||||
|
expect(docs[1]).toEqual({
|
||||||
|
docType : 'var',
|
||||||
|
name : 'privateClass',
|
||||||
|
id : 'privateClass',
|
||||||
|
returnType : 'InjectableReference'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
0
scripts/docs/typescript-package/services/modules.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/modules.js
Normal file → Executable file
21
scripts/docs/typescript-package/services/tsParser/createCompilerHost.js
Normal file → Executable file
21
scripts/docs/typescript-package/services/tsParser/createCompilerHost.js
Normal file → Executable file
@ -58,17 +58,22 @@ module.exports = function createCompilerHost(log) {
|
|||||||
return ts.sys.newLine;
|
return ts.sys.newLine;
|
||||||
},
|
},
|
||||||
fileExists: function (fileName) {
|
fileExists: function (fileName) {
|
||||||
var resolvedPath = path.resolve(baseDir, fileName);
|
var text, resolvedPath, resolvedPathWithExt;
|
||||||
try {
|
|
||||||
fs.statSync(resolvedPath);
|
// Strip off the extension and resolve relative to the baseDir
|
||||||
return true;
|
baseFilePath = fileName.replace(/\.[^.]+$/, '');
|
||||||
} catch (e) {
|
resolvedPath = path.resolve(baseDir, baseFilePath);
|
||||||
return false;
|
|
||||||
|
// Iterate through each possible extension and return the first source file that is actually found
|
||||||
|
for(var i=0; i<extensions.length; i++) {
|
||||||
|
// Try reading the content from files using each of the given extensions
|
||||||
|
resolvedPathWithExt = resolvedPath + extensions[i];
|
||||||
|
if (fs.existsSync(resolvedPathWithExt)) return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
readFile: function(fileName) {
|
readFile: function(fileName) {
|
||||||
var resolvedPath = path.resolve(baseDir, fileName);
|
console.log('readFile - NOT IMPLEMENTED', fileName);
|
||||||
return fs.readFileSync(resolvedPath, { encoding: options.charset });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
2
scripts/docs/typescript-package/services/tsParser/createCompilerHost.spec.js
Normal file → Executable file
2
scripts/docs/typescript-package/services/tsParser/createCompilerHost.spec.js
Normal file → Executable file
@ -38,7 +38,7 @@ describe('createCompilerHost', function() {
|
|||||||
|
|
||||||
describe('getDefaultLibFileName', function() {
|
describe('getDefaultLibFileName', function() {
|
||||||
it('should return a path to the default library', function() {
|
it('should return a path to the default library', function() {
|
||||||
expect(host.getDefaultLibFileName(options)).toContain('typescript/bin/lib.d.ts');
|
expect(host.getDefaultLibFileName(options)).toContain('typescript/lib/lib.d.ts');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
0
scripts/docs/typescript-package/services/tsParser/getContent.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/tsParser/getContent.js
Normal file → Executable file
@ -1,34 +0,0 @@
|
|||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
|
18
scripts/docs/typescript-package/services/tsParser/getExportDocType.js
Normal file → Executable file
18
scripts/docs/typescript-package/services/tsParser/getExportDocType.js
Normal file → Executable file
@ -3,12 +3,6 @@ var ts = require('typescript');
|
|||||||
module.exports = function getExportDocType(log) {
|
module.exports = function getExportDocType(log) {
|
||||||
|
|
||||||
return function(symbol) {
|
return function(symbol) {
|
||||||
if(symbol.flags & ts.SymbolFlags.FunctionScopedVariable) {
|
|
||||||
return 'var';
|
|
||||||
}
|
|
||||||
if(symbol.flags & ts.SymbolFlags.BlockScopedVariable) {
|
|
||||||
return getBlockScopedVariableDocType(symbol);
|
|
||||||
}
|
|
||||||
if(symbol.flags & ts.SymbolFlags.Function) {
|
if(symbol.flags & ts.SymbolFlags.Function) {
|
||||||
return 'function';
|
return 'function';
|
||||||
}
|
}
|
||||||
@ -30,6 +24,12 @@ module.exports = function getExportDocType(log) {
|
|||||||
if(symbol.flags & ts.SymbolFlags.TypeAlias) {
|
if(symbol.flags & ts.SymbolFlags.TypeAlias) {
|
||||||
return 'type-alias';
|
return 'type-alias';
|
||||||
}
|
}
|
||||||
|
if(symbol.flags & ts.SymbolFlags.FunctionScopedVariable) {
|
||||||
|
return 'var';
|
||||||
|
}
|
||||||
|
if(symbol.flags & ts.SymbolFlags.BlockScopedVariable) {
|
||||||
|
return getBlockScopedVariableDocType(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
log.warn('getExportDocType(): Unknown symbol type', {
|
log.warn('getExportDocType(): Unknown symbol type', {
|
||||||
symbolName: symbol.name,
|
symbolName: symbol.name,
|
||||||
@ -38,16 +38,14 @@ module.exports = function getExportDocType(log) {
|
|||||||
file: ts.getSourceFileOfNode(symbol.declarations[0]).fileName
|
file: ts.getSourceFileOfNode(symbol.declarations[0]).fileName
|
||||||
});
|
});
|
||||||
return 'unknown';
|
return 'unknown';
|
||||||
}
|
};
|
||||||
|
|
||||||
function getBlockScopedVariableDocType(symbol) {
|
function getBlockScopedVariableDocType(symbol) {
|
||||||
|
|
||||||
var node = symbol.valueDeclaration;
|
var node = symbol.valueDeclaration;
|
||||||
while(node) {
|
while(node) {
|
||||||
if ( node.flags & 0x2000 /* const */) {
|
if ( node.flags & 0x2000 /* const */) {
|
||||||
// DefinitelyTyped is still TS 1.4 so const is not allowed.
|
return 'const';
|
||||||
// https://github.com/borisyankov/DefinitelyTyped/issues/4564
|
|
||||||
return 'var'; // change to const when targetting TS 1.5
|
|
||||||
}
|
}
|
||||||
node = node.parent;
|
node = node.parent;
|
||||||
}
|
}
|
||||||
|
0
scripts/docs/typescript-package/services/tsParser/getFileInfo.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/tsParser/getFileInfo.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/tsParser/index.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/tsParser/index.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/tsParser/index.spec.js
Normal file → Executable file
0
scripts/docs/typescript-package/services/tsParser/index.spec.js
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user