From 9c55afdfdeb2dd11c1032774f4ce08ac8f5e105e Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Wed, 14 Sep 2016 07:50:02 +0100 Subject: [PATCH] fix(api-builder): pass versionInfo to macros The update to dgeni-packages led to a breaking change in the Nunjucks templates, where macros are now isolated from their calling site. This means that we must pass the `versionInfo` object through to the macro rather than expecting it to be in scope already. --- .../angular.io-package/templates/class.template.html | 2 +- .../angular.io-package/templates/decorator.template.html | 2 +- .../angular.io-package/templates/function.template.html | 2 +- .../angular.io-package/templates/interface.template.html | 2 +- .../angular.io-package/templates/lib/githubLinks.html | 6 +++--- .../angular.io-package/templates/module.template.html | 2 +- .../templates/overview-dump.template.html | 6 +++--- .../angular.io-package/templates/pipe.template.html | 2 +- .../angular.io-package/templates/var.template.html | 2 +- .../api-builder/docs-package/templates/module.template.html | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) 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 06785cc5fd..5320115240 100644 --- a/tools/api-builder/angular.io-package/templates/class.template.html +++ b/tools/api-builder/angular.io-package/templates/class.template.html @@ -140,6 +140,6 @@ div(layout="row" layout-xs="column" class="instance-members" class="row-margin n p(class="location-badge"). exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }, - defined in {$ github.githubViewLink(doc) $} + defined in {$ github.githubViewLink(doc, versionInfo) $} {% endblock %} diff --git a/tools/api-builder/angular.io-package/templates/decorator.template.html b/tools/api-builder/angular.io-package/templates/decorator.template.html index 1303ef9cd9..1a915a5932 100644 --- a/tools/api-builder/angular.io-package/templates/decorator.template.html +++ b/tools/api-builder/angular.io-package/templates/decorator.template.html @@ -46,6 +46,6 @@ div(layout="row" layout-xs="column" class="metadata" class="row-margin ng-cloak" {% endif %} p.location-badge. - exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } defined in {$ github.githubViewLink(doc) $} + exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } defined in {$ github.githubViewLink(doc, versionInfo) $} {% endblock %} 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 7cf1d85640..49c05f1c9a 100644 --- a/tools/api-builder/angular.io-package/templates/function.template.html +++ b/tools/api-builder/angular.io-package/templates/function.template.html @@ -26,6 +26,6 @@ div(layout="row" layout-xs="column" class="row-margin ng-cloak") {% endif %} p.location-badge. - exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } defined in {$ github.githubViewLink(doc) $} + exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } defined in {$ github.githubViewLink(doc, versionInfo) $} {% endblock %} \ No newline at end of file diff --git a/tools/api-builder/angular.io-package/templates/interface.template.html b/tools/api-builder/angular.io-package/templates/interface.template.html index 59d7ae7cc5..1567e4cf35 100644 --- a/tools/api-builder/angular.io-package/templates/interface.template.html +++ b/tools/api-builder/angular.io-package/templates/interface.template.html @@ -68,6 +68,6 @@ div(layout="row" layout-xs="column" class="instance-members" class="row-margin n p(class="location-badge"). exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }, - defined in {$ github.githubViewLink(doc) $} + defined in {$ github.githubViewLink(doc, versionInfo) $} {% endblock %} diff --git a/tools/api-builder/angular.io-package/templates/lib/githubLinks.html b/tools/api-builder/angular.io-package/templates/lib/githubLinks.html index 36ec6d0576..53d5132765 100644 --- a/tools/api-builder/angular.io-package/templates/lib/githubLinks.html +++ b/tools/api-builder/angular.io-package/templates/lib/githubLinks.html @@ -1,7 +1,7 @@ -{% macro githubHref(doc) -%} +{% macro githubHref(doc, versionInfo) -%} https://github.com/{$ versionInfo.gitRepoInfo.owner $}/{$ versionInfo.gitRepoInfo.repo $}/tree/{$ versionInfo.currentVersion.isSnapshot and versionInfo.currentVersion.SHA or versionInfo.currentVersion.raw $}/modules/{$ doc.fileInfo.projectRelativePath $}#L{$ doc.location.start.line+1 $}-L{$ doc.location.end.line+1 $} {%- endmacro %} -{% macro githubViewLink(doc) -%} - {$ doc.fileInfo.projectRelativePath $} +{% macro githubViewLink(doc, versionInfo) -%} + {$ doc.fileInfo.projectRelativePath $} {%- endmacro %} 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 d047e67fb1..7f19dd44c5 100644 --- a/tools/api-builder/angular.io-package/templates/module.template.html +++ b/tools/api-builder/angular.io-package/templates/module.template.html @@ -3,7 +3,7 @@ {% block body -%} include {$ relativePath(doc.path, '_util-fns') $} p.location-badge. - defined in {$ github.githubViewLink(doc) $} + defined in {$ github.githubViewLink(doc, versionInfo) $} ul {% for page in doc.childPages -%} diff --git a/tools/api-builder/angular.io-package/templates/overview-dump.template.html b/tools/api-builder/angular.io-package/templates/overview-dump.template.html index e02c70adff..86e1b72e0e 100644 --- a/tools/api-builder/angular.io-package/templates/overview-dump.template.html +++ b/tools/api-builder/angular.io-package/templates/overview-dump.template.html @@ -47,20 +47,20 @@ {% for export in module.exports %}

- + {$ export.docType $} {$ export.name $}

{%- if export.constructorDoc %}

- + {$ export.constructorDoc.name $}{$ params.paramList(export.constructorDoc.params) $}

{% endif -%} {%- for member in export.members %}

- + {$ member.name $}{$ params.paramList(member.params) $}

diff --git a/tools/api-builder/angular.io-package/templates/pipe.template.html b/tools/api-builder/angular.io-package/templates/pipe.template.html index 86db8582a2..068333cc40 100644 --- a/tools/api-builder/angular.io-package/templates/pipe.template.html +++ b/tools/api-builder/angular.io-package/templates/pipe.template.html @@ -24,6 +24,6 @@ div(layout="row" layout-xs="column" class="row-margin ng-cloak") p(class="location-badge"). exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } - defined in {$ github.githubViewLink(doc) $} + defined in {$ github.githubViewLink(doc, versionInfo) $} {% endblock %} 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 6985ec43ff..741558eaca 100644 --- a/tools/api-builder/angular.io-package/templates/var.template.html +++ b/tools/api-builder/angular.io-package/templates/var.template.html @@ -27,6 +27,6 @@ div(layout="row" layout-xs="column" class="row-margin ng-cloak") p.location-badge. exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } - defined in {$ github.githubViewLink(doc) $} + defined in {$ github.githubViewLink(doc, versionInfo) $} {% endblock %} diff --git a/tools/api-builder/docs-package/templates/module.template.html b/tools/api-builder/docs-package/templates/module.template.html index c4b7360141..fb7e79e2d0 100644 --- a/tools/api-builder/docs-package/templates/module.template.html +++ b/tools/api-builder/docs-package/templates/module.template.html @@ -3,7 +3,7 @@ {% block body %}

{$ doc.id $} module

-

defined in {$ github.githubViewLink(doc) $}

+

defined in {$ github.githubViewLink(doc, versionInfo) $}

{$ doc.description | marked $}

{% if doc.exports.length %}