diff --git a/tools/api-builder/angular.io-package/index.js b/tools/api-builder/angular.io-package/index.js index ac948b21e4..b0ac6194cb 100644 --- a/tools/api-builder/angular.io-package/index.js +++ b/tools/api-builder/angular.io-package/index.js @@ -23,10 +23,15 @@ module.exports = new Package('angular.io', [basePackage, targetPackage, cheatshe .factory(require('./services/packageInfo')) // Configure rendering -.config(function(templateFinder, templateEngine) { +.config(function(templateFinder, templateEngine, renderDocsProcessor) { templateFinder.templateFolders .unshift(path.resolve(__dirname, 'templates')); + + // helpers are made available to the nunjucks templates + renderDocsProcessor.helpers.relativePath = function(from, to) { + return path.relative(from, to); + }; }) .config(function(parseTagsProcessor) { @@ -71,20 +76,23 @@ module.exports = new Package('angular.io', [basePackage, targetPackage, cheatshe computePathsProcessor.pathTemplates.push({ docTypes: ['module'], getPath: function computeModulePath(doc) { - return doc.id.replace(/^angular2\//, ''); + doc.moduleFolder = doc.id.replace(/^angular2\//, ''); + return doc.moduleFolder + '/index.html'; }, - outputPathTemplate: '${path}/index.jade' + getOutputPath: function computeModulePath(doc) { + return doc.moduleFolder + '/index.jade'; + } }); computePathsProcessor.pathTemplates.push({ docTypes: EXPORT_DOC_TYPES, - pathTemplate: '${moduleDoc.path}/${name}-${docType}.html', - outputPathTemplate:'${moduleDoc.path}/${name}-${docType}.jade', + pathTemplate: '${moduleDoc.moduleFolder}/${name}-${docType}.html', + outputPathTemplate:'${moduleDoc.moduleFolder}/${name}-${docType}.jade', }); computePathsProcessor.pathTemplates.push({ docTypes: ['jade-data'], - pathTemplate: '${originalDoc.path}/_data', + pathTemplate: '${originalDoc.moduleFolder}/_data', outputPathTemplate: '${path}.json' }); diff --git a/tools/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js b/tools/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js index aff3b7bd2b..46c6690faa 100644 --- a/tools/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js +++ b/tools/api-builder/angular.io-package/processors/addJadeDataDocsProcessor.js @@ -71,6 +71,9 @@ module.exports = function addJadeDataDocsProcessor() { .sortBy('name') .value(); + doc.childPages = modulePageInfo; + console.log(doc.childPages); + // ADD TO APP DATA DOC appDataDoc.data[doc.id] = modulePageInfo; diff --git a/tools/api-builder/angular.io-package/templates/class.template.html b/tools/api-builder/angular.io-package/templates/class.template.html index 2db46a1fc4..2c516b7ce6 100644 --- a/tools/api-builder/angular.io-package/templates/class.template.html +++ b/tools/api-builder/angular.io-package/templates/class.template.html @@ -3,7 +3,7 @@ {% extends 'layout/base.template.html' -%} {% block body %} -include ../../_util-fns +include {$ relativePath(doc.path, '_util-fns') $} h2(class="{$ doc.docType $} export") pre.prettyprint diff --git a/tools/api-builder/angular.io-package/templates/function.template.html b/tools/api-builder/angular.io-package/templates/function.template.html index ae878d9177..d02983310b 100644 --- a/tools/api-builder/angular.io-package/templates/function.template.html +++ b/tools/api-builder/angular.io-package/templates/function.template.html @@ -3,7 +3,7 @@ {% extends 'layout/base.template.html' -%} {% block body %} -include ../../_util-fns +include {$ relativePath(doc.path, '_util-fns') $} .l-main-section h2(class="function export") pre.prettyprint diff --git a/tools/api-builder/angular.io-package/templates/module.template.html b/tools/api-builder/angular.io-package/templates/module.template.html index 0664b8113e..fb62f190e4 100644 --- a/tools/api-builder/angular.io-package/templates/module.template.html +++ b/tools/api-builder/angular.io-package/templates/module.template.html @@ -1,16 +1,13 @@ {% include "lib/githubLinks.html" -%} {% extends 'layout/base.template.html' -%} {% block body -%} -include ../../_util-fns +include {$ relativePath(doc.path, '_util-fns') $} p.location-badge. defined in {$ githubViewLink(doc) $} ul - for page, slug in public.docs[current.path[1]][current.path[2]][current.path[3]][current.path[4]]._data - if slug != 'index' - - var url = "/docs/" + current.path[1] + "/" + current.path[2] + "/" + current.path[3] + "/" + current.path[4] + "/" + slug + ".html" - - li - != partial("../../../../../_includes/_hover-card", {name: page.title, url: url }) - + {% for page in doc.childPages -%} + li + != partial("{$ relativePath(doc.path, '../../../_includes/_hover-card') $}", {name: "{$ page.title $}", url: "{$ relativePath(doc.moduleFolder, page.exportDoc.path) $}" }) + {% endfor %} {% endblock %} \ No newline at end of file diff --git a/tools/api-builder/angular.io-package/templates/var.template.html b/tools/api-builder/angular.io-package/templates/var.template.html index a37f844a0c..ed06f6e93a 100644 --- a/tools/api-builder/angular.io-package/templates/var.template.html +++ b/tools/api-builder/angular.io-package/templates/var.template.html @@ -3,7 +3,7 @@ {% extends 'layout/base.template.html' %} {% block body %} -include ../../_util-fns +include {$ relativePath(doc.path, '_util-fns') $} .l-main-section h2(class="variable export") pre.prettyprint