chore(doc-gen): make the module of the export's original declaration available

This commit is contained in:
Peter Bacon Darwin
2015-09-16 21:35:35 +01:00
committed by Naomi Black
parent 19274e744d
commit dad40751d4
7 changed files with 38 additions and 12 deletions

View File

@ -0,0 +1 @@
export var x = 10;

View File

@ -0,0 +1 @@
export { x as y} from './privateModule';

View File

@ -223,6 +223,11 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
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;
}

View File

@ -14,6 +14,18 @@ describe('readTypeScriptModules', function() {
});
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');
});
});
describe('ignoreExportsMatching', function() {
it('should ignore exports that match items in the `ignoreExportsMatching` property', function() {
processor.sourceFiles = [ 'ignoreExportsMatching.ts'];