From 834b65dca3fac05132bc6009d75a3aa52aaaa154 Mon Sep 17 00:00:00 2001 From: Jay Traband Date: Thu, 17 Sep 2015 01:40:45 -0700 Subject: [PATCH] cleanup/comment api builder --- .gitignore | 1 + .../api-builder/angular.io-package/index.js | 30 +++++++++++-------- .../processors/fixOutputPathProcessor.js | 23 ++++++++++++++ .../templates/class.template.html | 2 +- public/api-builder/docs-package/index.js | 1 + 5 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 public/api-builder/angular.io-package/processors/fixOutputPathProcessor.js diff --git a/.gitignore b/.gitignore index af26b26748..4a188a5486 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ typings www .DS_Store .idea +**/js/latest/api \ No newline at end of file diff --git a/public/api-builder/angular.io-package/index.js b/public/api-builder/angular.io-package/index.js index 02664bd764..90ebbda1f5 100644 --- a/public/api-builder/angular.io-package/index.js +++ b/public/api-builder/angular.io-package/index.js @@ -2,17 +2,16 @@ var path = require('canonical-path'); var Package = require('dgeni').Package; var basePackage = require('../public-docs-package'); -var PARTIAL_PATH = 'partials'; -var MODULES_DOCS_PATH = PARTIAL_PATH + '/api'; - -// OLD paths -// var DOCS_DIST = 'dist/angular.io/partials/api/angular2/'; -// var DOCS_IO_DIST = '../angular.io/public/docs/js/latest/api/'; +// MIGRATION: removed these vars +// var PARTIAL_PATH = 'partials'; +// var MODULES_DOCS_PATH = PARTIAL_PATH + '/api'; module.exports = new Package('angular.io', [basePackage]) .factory(require('./services/renderMarkdown')) .processor(require('./processors/addJadeDataDocsProcessor')) +// MIGRATION: added this processor +.processor(require('./processors/fixOutputPathProcessor')) // overrides base packageInfo and returns the one for the 'angular/angular' repo. .factory(require('./services/packageInfo')) @@ -24,37 +23,44 @@ module.exports = new Package('angular.io', [basePackage]) }) .config(function(writeFilesProcessor) { - writeFilesProcessor.outputFolder = 'dist/angular.io'; + writeFilesProcessor.outputFolder = 'js/latest/api'; }) .config(function(readFilesProcessor, generateNavigationDoc, createOverviewDump) { // Clear out unwanted processors + // MIGRATION: HACK - added basePath to point to a local repo location because the docs-package-processor will + // have previously set it to point to angular/angular repo. + readFilesProcessor.basePath = path.resolve(__dirname, "../../docs"); readFilesProcessor.$enabled = false; generateNavigationDoc.$enabled = false; createOverviewDump.$enabled = false; }) - - .config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) { computePathsProcessor.pathTemplates.push({ docTypes: ['module'], pathTemplate: '${id}/', - outputPathTemplate: MODULES_DOCS_PATH + '/${id}/index.jade' + // MIGRATION: + // outputPathTemplate: MODULES_DOCS_PATH + '/${id}/index.jade' + outputPathTemplate: '/${id}/index.jade' }); computePathsProcessor.pathTemplates.push({ docTypes: EXPORT_DOC_TYPES, pathTemplate: '${moduleDoc.id}/${name}-${docType}.html', - outputPathTemplate: MODULES_DOCS_PATH + '/${moduleDoc.id}/${name}-${docType}.jade', + // MIGRATION: + // outputPathTemplate: MODULES_DOCS_PATH + '/${moduleDoc.id}/${name}-${docType}.jade', + outputPathTemplate:'/${moduleDoc.id}/${name}-${docType}.jade', }); computePathsProcessor.pathTemplates.push({ docTypes: ['jade-data'], pathTemplate: '${originalDoc.id}/_data', - outputPathTemplate: MODULES_DOCS_PATH + '/${path}.json' + // MIGRATION: + // outputPathTemplate: MODULES_DOCS_PATH + '/${path}.json' + outputPathTemplate: '/${path}.json' }); }) diff --git a/public/api-builder/angular.io-package/processors/fixOutputPathProcessor.js b/public/api-builder/angular.io-package/processors/fixOutputPathProcessor.js new file mode 100644 index 0000000000..9511c360d9 --- /dev/null +++ b/public/api-builder/angular.io-package/processors/fixOutputPathProcessor.js @@ -0,0 +1,23 @@ +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; + } + }; +}; diff --git a/public/api-builder/angular.io-package/templates/class.template.html b/public/api-builder/angular.io-package/templates/class.template.html index a51fc5fb08..b8bdd56691 100644 --- a/public/api-builder/angular.io-package/templates/class.template.html +++ b/public/api-builder/angular.io-package/templates/class.template.html @@ -8,7 +8,7 @@ p.location-badge. defined in {$ githubViewLink(doc) $} :markdown -{$ doc.moduleDoc.description | indent(2, true) | trimBlankLines $} +{$ doc.description | indent(2, true) | trimBlankLines $} {%- if doc.decorators %} .l-main-section diff --git a/public/api-builder/docs-package/index.js b/public/api-builder/docs-package/index.js index b456ea6b3d..a898a01f6e 100644 --- a/public/api-builder/docs-package/index.js +++ b/public/api-builder/docs-package/index.js @@ -33,6 +33,7 @@ module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage, // Configure file reading .config(function(readFilesProcessor, ngdocFileReader, readTypeScriptModules) { readFilesProcessor.fileReaders = [ngdocFileReader]; + // MIGRATION: set the readFilesProcessor base path to point to angular repo. var angular_repo_path = path.resolve(__dirname, '../../../../angular'); // TODO: confirm that the angular repo is actually there. if (!fs.existsSync(angular_repo_path)) {