refact(angular.io-package): compute the correct path rather than fixing up later

This commit is contained in:
Peter Bacon Darwin 2015-09-18 13:05:58 +01:00 committed by Jay Traband
parent 166d932ee4
commit 39f1959f2e
3 changed files with 13 additions and 34 deletions

View File

@ -10,8 +10,7 @@ module.exports = new Package('angular.io', [basePackage])
.factory(require('./services/renderMarkdown'))
.processor(require('./processors/addJadeDataDocsProcessor'))
// MIGRATION: added this processor
.processor(require('./processors/fixOutputPathProcessor'))
// MIGRATION: added packageInfo to point to angular/angular repo
// overrides base packageInfo and returns the one for the 'angular/angular' repo.
.factory(require('./services/packageInfo'))
@ -59,26 +58,28 @@ module.exports = new Package('angular.io', [basePackage])
computePathsProcessor.pathTemplates.push({
docTypes: ['module'],
pathTemplate: '${id}/',
getPath: function computeModulePath(doc) {
return doc.id.replace(/^angular2\//, '');
},
// MIGRATION:
// outputPathTemplate: MODULES_DOCS_PATH + '/${id}/index.jade'
outputPathTemplate: '/${id}/index.jade'
outputPathTemplate: '${path}/index.jade'
});
computePathsProcessor.pathTemplates.push({
docTypes: EXPORT_DOC_TYPES,
pathTemplate: '${moduleDoc.id}/${name}-${docType}.html',
pathTemplate: '${moduleDoc.path}/${name}-${docType}.html',
// MIGRATION:
// outputPathTemplate: MODULES_DOCS_PATH + '/${moduleDoc.id}/${name}-${docType}.jade',
outputPathTemplate:'/${moduleDoc.id}/${name}-${docType}.jade',
outputPathTemplate:'${moduleDoc.path}/${name}-${docType}.jade',
});
computePathsProcessor.pathTemplates.push({
docTypes: ['jade-data'],
pathTemplate: '${originalDoc.id}/_data',
pathTemplate: '${originalDoc.path}/_data',
// MIGRATION:
// outputPathTemplate: MODULES_DOCS_PATH + '/${path}.json'
outputPathTemplate: '/${path}.json'
outputPathTemplate: '${path}.json'
});
})

View File

@ -1,23 +0,0 @@
var _ = require('lodash');
var path = require('canonical-path');
/*
* Remove angular2 prefix from all doc output paths
*/
module.exports = function fixOutputPathProcessor() {
return {
$runAfter: ['paths-computed'],
$runBefore: ['writing-files'],
$process: function(docs) {
docs.forEach(function(doc) {
try {
doc.outputPath = doc.outputPath && path.relative("/angular2", doc.outputPath);
} catch(e) {
var x = e;
}
});
return docs;
}
};
};

View File

@ -63,6 +63,10 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
var exportDoc = createExportDoc(exportSymbol.name, resolvedExport, moduleDoc, basePath, parseInfo.typeChecker);
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 = [];
@ -123,9 +127,6 @@ module.exports = function readTypeScriptModules(tsParser, modules, getFileInfo,
});
}
// Add this export doc to its module doc
moduleDoc.exports.push(exportDoc);
docs.push(exportDoc);
});
});
}