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.
This commit is contained in:
Peter Bacon Darwin 2016-09-14 07:50:02 +01:00 committed by Naomi Black
parent 37953e8a06
commit 9c55afdfde
10 changed files with 14 additions and 14 deletions

View File

@ -140,6 +140,6 @@ div(layout="row" layout-xs="column" class="instance-members" class="row-margin n
p(class="location-badge"). p(class="location-badge").
exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }, exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} },
defined in {$ github.githubViewLink(doc) $} defined in {$ github.githubViewLink(doc, versionInfo) $}
{% endblock %} {% endblock %}

View File

@ -46,6 +46,6 @@ div(layout="row" layout-xs="column" class="metadata" class="row-margin ng-cloak"
{% endif %} {% endif %}
p.location-badge. 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 %} {% endblock %}

View File

@ -26,6 +26,6 @@ div(layout="row" layout-xs="column" class="row-margin ng-cloak")
{% endif %} {% endif %}
p.location-badge. 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 %} {% endblock %}

View File

@ -68,6 +68,6 @@ div(layout="row" layout-xs="column" class="instance-members" class="row-margin n
p(class="location-badge"). p(class="location-badge").
exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }, exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} },
defined in {$ github.githubViewLink(doc) $} defined in {$ github.githubViewLink(doc, versionInfo) $}
{% endblock %} {% endblock %}

View File

@ -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 $} 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 %} {%- endmacro %}
{% macro githubViewLink(doc) -%} {% macro githubViewLink(doc, versionInfo) -%}
<a href="{$ githubHref(doc) $}">{$ doc.fileInfo.projectRelativePath $}</a> <a href="{$ githubHref(doc, versionInfo) $}">{$ doc.fileInfo.projectRelativePath $}</a>
{%- endmacro %} {%- endmacro %}

View File

@ -3,7 +3,7 @@
{% block body -%} {% block body -%}
include {$ relativePath(doc.path, '_util-fns') $} include {$ relativePath(doc.path, '_util-fns') $}
p.location-badge. p.location-badge.
defined in {$ github.githubViewLink(doc) $} defined in {$ github.githubViewLink(doc, versionInfo) $}
ul ul
{% for page in doc.childPages -%} {% for page in doc.childPages -%}

View File

@ -47,20 +47,20 @@
{% for export in module.exports %} {% for export in module.exports %}
<h3 {% if export.notYetDocumented %}class="not-documented"{% endif %}> <h3 {% if export.notYetDocumented %}class="not-documented"{% endif %}>
<a href="{$ github.githubHref(export) $}"> <a href="{$ github.githubHref(export, versionInfo) $}">
<code>{$ export.docType $} {$ export.name $}</code> <code>{$ export.docType $} {$ export.name $}</code>
</a> </a>
</h3> </h3>
{%- if export.constructorDoc %} {%- if export.constructorDoc %}
<h4 {% if export.constructorDoc.notYetDocumented %}class="not-documented"{% endif %}> <h4 {% if export.constructorDoc.notYetDocumented %}class="not-documented"{% endif %}>
<a href="{$ github.githubHref(export.constructorDoc) $}"> <a href="{$ github.githubHref(export.constructorDoc, versionInfo) $}">
<code>{$ export.constructorDoc.name $}{$ params.paramList(export.constructorDoc.params) $}</code> <code>{$ export.constructorDoc.name $}{$ params.paramList(export.constructorDoc.params) $}</code>
</a> </a>
</h4> </h4>
{% endif -%} {% endif -%}
{%- for member in export.members %} {%- for member in export.members %}
<h4 {% if member.notYetDocumented %}class="not-documented"{% endif %}> <h4 {% if member.notYetDocumented %}class="not-documented"{% endif %}>
<a href="{$ github.githubHref(member) $}"> <a href="{$ github.githubHref(member, versionInfo) $}">
<code>{$ member.name $}{$ params.paramList(member.params) $}</code> <code>{$ member.name $}{$ params.paramList(member.params) $}</code>
</a> </a>
</h4> </h4>

View File

@ -24,6 +24,6 @@ div(layout="row" layout-xs="column" class="row-margin ng-cloak")
p(class="location-badge"). p(class="location-badge").
exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }
defined in {$ github.githubViewLink(doc) $} defined in {$ github.githubViewLink(doc, versionInfo) $}
{% endblock %} {% endblock %}

View File

@ -27,6 +27,6 @@ div(layout="row" layout-xs="column" class="row-margin ng-cloak")
p.location-badge. p.location-badge.
exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} } exported from {@link {$ doc.moduleDoc.id $} {$doc.moduleDoc.id $} }
defined in {$ github.githubViewLink(doc) $} defined in {$ github.githubViewLink(doc, versionInfo) $}
{% endblock %} {% endblock %}

View File

@ -3,7 +3,7 @@
{% block body %} {% block body %}
<h1 class="id">{$ doc.id $} <span class="type">module</span></h1> <h1 class="id">{$ doc.id $} <span class="type">module</span></h1>
<p>defined in {$ github.githubViewLink(doc) $}</p> <p>defined in {$ github.githubViewLink(doc, versionInfo) $}</p>
<p>{$ doc.description | marked $}</p> <p>{$ doc.description | marked $}</p>
{% if doc.exports.length %} {% if doc.exports.length %}