
{%- 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(member) -%}
{$ commentBlock(member, 5) $}
     {$ member.name $}{% if member.optional %}?{% endif -%}
{% if member.typeParameters %}<{% for typeParam in member.typeParameters %}{$ typeParam $}{% if not loop.last %}, {% endif %}{% endfor %}>{% endif -%}
{%- if member.parameters -%}({% for param in member.parameters %}{$ param $}{% if not loop.last %}, {% endif %}{% endfor %}){%- endif -%}
{%- if member.returnType == 'Directive' %}: DirectiveAnnotation{%- elif member.returnType -%}: {$ member.returnType $}{%- else -%}: void
{%- endif -%};
{%- 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.
// ***********************************************************
{% block staticDeclarations %}{% endblock %}
{% for alias, module in doc.moduleDocs %}
{$ commentBlock(module.doc, 1) $}
declare module ng {

  {%- 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(export.newMember) $}
  {% endif %}
  {%- if export.callMember %}
    {$ memberInfo(export.callMember) $}
  {% endif -%}
  {%- for member in export.members %}
    {$ memberInfo(member) $}
  {%- endfor %}
  }

  {%- elif export.docType == 'enum' %} {
    {%- for member in export.members %}
    {$ member $}{% 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 %}
}

{% endfor %}

declare module "angular2/angular2" {
  export = ng;
}
