dgeni-packages
Advanced tools
Comparing version 0.16.9 to 0.16.10
# Changelog | ||
# 0.16.10 7 March 2017 | ||
* REVERT: feat(typescript): link `class` docs to inherited class docs cf8b7444 | ||
# 0.16.9 6 March 2017 | ||
@@ -4,0 +8,0 @@ |
{ | ||
"name": "dgeni-packages", | ||
"version": "0.16.9", | ||
"version": "0.16.10", | ||
"description": "A collection of dgeni packages for generating documentation from source code", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -17,3 +17,2 @@ var Package = require('dgeni').Package; | ||
.factory(require('./services/convertPrivateClassesToInterfaces')) | ||
.factory(require('./services/typescript-symbol-map')) | ||
@@ -40,3 +39,2 @@ .factory('EXPORT_DOC_TYPES', function() { | ||
.processor(require('./processors/readTypeScriptModules')) | ||
.processor(require('./processors/linkInheritedDocs')) | ||
@@ -43,0 +41,0 @@ // Configure ids and paths |
@@ -6,5 +6,4 @@ var glob = require('glob'); | ||
module.exports = function readTypeScriptModules( | ||
tsParser, modules, getFileInfo, ignoreTypeScriptNamespaces, getExportDocType, | ||
getExportAccessibility, getContent, createDocMessage, log, typescriptSymbolMap) { | ||
module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo, ignoreTypeScriptNamespaces, | ||
getExportDocType, getExportAccessibility, getContent, createDocMessage, log) { | ||
@@ -46,3 +45,2 @@ return { | ||
var moduleSymbols = parseInfo.moduleSymbols; | ||
var typeChecker = parseInfo.typeChecker; | ||
@@ -74,3 +72,3 @@ // Iterate through each of the modules that were parsed and generate a module doc | ||
var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, typeChecker); | ||
var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, parseInfo.typeChecker); | ||
log.debug('>>>> EXPORT: ' + exportDoc.name + ' (' + exportDoc.docType + ') from ' + moduleDoc.id); | ||
@@ -85,8 +83,2 @@ | ||
// Store the dgeni doc of the resolved symbol in the typescriptSymbolMap. | ||
typescriptSymbolMap.set(resolvedExport, exportDoc); | ||
// Resolve all inherited symbols and store them inside of the exportDoc object. | ||
exportDoc.inheritedSymbols = resolveInheritedSymbols(resolvedExport, typeChecker); | ||
// Generate docs for each of the export's members | ||
@@ -102,3 +94,3 @@ if (resolvedExport.flags & ts.SymbolFlags.HasMembers) { | ||
var memberSymbol = resolvedExport.members[memberName]; | ||
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, typeChecker); | ||
var memberDoc = createMemberDoc(memberSymbol, exportDoc, basePath, parseInfo.typeChecker); | ||
@@ -159,39 +151,3 @@ // We special case the constructor and sort the other members alphabetically | ||
/** | ||
* Resolves all inherited class symbols of the specified symbol. | ||
* @param {ts.Symbol} symbol ClassDeclaration symbol with members | ||
* @param {ts.TypeChecker} typeChecker TypeScript TypeChecker for symbols | ||
* @returns {Symbol[]} List of inherited class symbols. | ||
**/ | ||
function resolveInheritedSymbols(symbol, typeChecker) { | ||
var declaration = symbol.valueDeclaration || symbol.declarations[0]; | ||
var symbols = []; | ||
if (declaration && declaration.heritageClauses) { | ||
symbols = declaration.heritageClauses | ||
// Filter for extends heritage clauses. | ||
.filter(isExtendsHeritage) | ||
// Resolve an array of the inherited symbols from the heritage clause. | ||
.map(heritage => convertHeritageClauseToSymbols(heritage, typeChecker)) | ||
// Flatten the arrays of inherited symbols. | ||
.reduce((symbols, cur) => symbols.concat(cur), []); | ||
} | ||
return symbols; | ||
} | ||
/** | ||
* Converts a heritage clause into a list of symbols | ||
* @param {ts.HeritageClause} heritage | ||
* @param {ts.TypeChecker} typeChecker | ||
* @returns {ts.SymbolTable} List of heritage symbols. | ||
**/ | ||
function convertHeritageClauseToSymbols(heritage, typeChecker) { | ||
var heritages = heritage.types.map(expression => | ||
typeChecker.getTypeAtLocation(expression).getSymbol() | ||
); | ||
return heritages.reduce((inheritances, current) => inheritances.concat(current), []); | ||
} | ||
function createModuleDoc(moduleSymbol, basePath) { | ||
@@ -242,3 +198,3 @@ var id = moduleSymbol.name.replace(/^"|"$/g, ''); | ||
if (isExtendsHeritage(heritage)) { | ||
if (heritage.token == ts.SyntaxKind.ExtendsKeyword) { | ||
heritageString += " extends"; | ||
@@ -504,6 +460,2 @@ heritage.types.forEach(function(typ, idx) { | ||
/** Checks if the specified heritage clause is an extends keyword. */ | ||
function isExtendsHeritage(heritageClause) { | ||
return heritageClause.token === ts.SyntaxKind.ExtendsKeyword | ||
} | ||
}; | ||
@@ -510,0 +462,0 @@ |
@@ -60,25 +60,3 @@ var mockPackage = require('../mocks/mockPackage'); | ||
describe('inherited symbols', function() { | ||
it('should add the list of inherited symbols to a class doc', function() { | ||
processor.sourceFiles = [ 'inheritedMembers.ts' ]; | ||
var docs = []; | ||
processor.$process(docs); | ||
var childDoc = docs[3]; | ||
var firstParentDoc = docs[5]; | ||
var lastParentDoc = docs[1]; | ||
expect(childDoc.inheritedSymbols.length).toBe(1); | ||
expect(childDoc.inheritedSymbols[0]).toBe(firstParentDoc.exportSymbol); | ||
expect(firstParentDoc.inheritedSymbols.length).toBe(1); | ||
expect(firstParentDoc.inheritedSymbols[0]).toBe(lastParentDoc.exportSymbol); | ||
expect(lastParentDoc.inheritedSymbols.length).toBe(0); | ||
}); | ||
}); | ||
describe('ignoreExportsMatching', function() { | ||
@@ -261,2 +239,2 @@ it('should ignore exports that match items in the `ignoreExportsMatching` property', function() { | ||
return collection.map(function(item) { return item.name; }); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
556747
363
10133