
{%- macro commentBlock(doc, level) -%}
{%- if doc.content | trim %}

{% if level > 1 %}{$ '/**' | indent(level-1, true) | replace(r/\n$/, "") $}{% else %}/**{% endif %}
{$ doc.content | trim | replace(r/^/gm, "* ") | indent(level, true) | replace(r/\n$/, "") $}
{$ '*/' | indent(level, true) | replace(r/\n$/, "") $}{% endif -%}
{%- endmacro -%}


{%- macro memberInfo(signature, member) -%}
{$ commentBlock(member, 5) $}
     {$ signature(member) $};
{%- endmacro -%}


// Type definitions for Angular v{$ versionInfo.currentVersion.full | replace(r/\+/, "_") $}
// Project: http://angular.io/
// Definitions by: angular team <https://github.com/angular/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

// ***********************************************************
// This file is generated by the Angular build process.
// Please do not create manual edits or send pull requests
// modifying this file.
// ***********************************************************
{% for alias, module in doc.moduleDocs %}
{%- if module.references.length %}
// {$ alias $} depends transitively on these libraries.
// If you don't have them installed you can install them using TSD
// https://github.com/DefinitelyTyped/tsd
{%- endif %}
{% for reference in module.references %}
///<reference path="{$ reference $}"/>{% endfor %}{% endfor %}
{% block staticDeclarations %}{% endblock %}
{% for alias, module in doc.moduleDocs %}
{$ commentBlock(module.doc, 1) $}
declare module {$ module.namespace $} {

  {%- for export in module.doc.exports -%}
  {%- if export.content -%}
    {$ commentBlock(export, 3) $}
  {%- endif %}
  {$ export.docType $} {$ export.name $}{$ export.typeParams $}{%- if export.heritage == ' extends Directive' %} extends DirectiveAnnotation{% else %}{$ export.heritage $}{% endif %}
  {%- if export.docType == 'class' or export.docType == 'interface' %} {
  {%- if export.newMember %}
    {$ memberInfo(doc.signature, export.newMember) $}
  {% endif %}
  {%- if export.callMember %}
    {$ memberInfo(doc.signature, export.callMember) $}
  {% endif -%}
  {%- for static in export.statics %}
    {$ memberInfo(doc.signature, static) $}
  {%- endfor -%}
  {%- for member in export.members %}
    {$ memberInfo(doc.signature, member) $}
  {%- endfor %}
  }

  {%- elif export.docType == 'enum' %} {
    {%- for member in export.members %}
    {$ commentBlock(member, 5) $}
     {$ member.name $}{% if not loop.last %},
    {%- endif -%}
    {%- endfor %}
  }

  {%- else -%}
    {% if export.parameters %}({% for param in export.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif %}
    {%- if export.returnType %} : {$ export.returnType $} {% endif -%}
    ;
  {%- endif %}
  {% endfor %}
}

declare module "{$ alias $}" {
  export = {$ module.namespace $};
}

{% endfor %}
