From f4b60588fbb4008e8ebf1dccd57607dc2f02dfc2 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Fri, 21 Sep 2018 14:06:57 +0100 Subject: [PATCH] build(docs-infra): move directive macros into memberHelpers.html (#25768) PR Close #25768 --- .../templates/api/directive.template.html | 28 ++------------- .../templates/api/lib/memberHelpers.html | 34 ++++++++++++++++--- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/aio/tools/transforms/templates/api/directive.template.html b/aio/tools/transforms/templates/api/directive.template.html index 55bb22ec37..1596da9825 100644 --- a/aio/tools/transforms/templates/api/directive.template.html +++ b/aio/tools/transforms/templates/api/directive.template.html @@ -1,37 +1,13 @@ {% import "lib/memberHelpers.html" as memberHelpers -%} {% extends 'class.template.html' -%} -{% macro renderAncestorMembers(doc, collectionName) %} -{%- for ancestor in doc.extendsClauses %}{% if ancestor.doc %} -{% set nonInternalMembers = ancestor.doc[collectionName] | filterByPropertyValue('internal', undefined) %} -{% if nonInternalMembers.length -%} -
-

Inherited from {$ ancestor.doc.id $}

- -
-{% endif %} -{$ renderAncestorMembers(ancestor.doc, collectionName) $} -{% endif %}{% endfor -%} -{% endmacro %} - -{% macro renderProperties(doc, heading) %} -{$ memberHelpers.renderProperties(doc.properties, 'instance-properties', 'instance-property', heading) $} -{$ renderAncestorMembers(doc, 'properties') $} -{% endmacro %} - {% block overview %}{% endblock %} {% block details -%} {% include "includes/ngmodule.html" %} {% include "includes/selectors.html" %} - {$ renderProperties(doc, 'Properties') $} + {$ memberHelpers.renderDirectiveProperties(doc, 'Properties') $} {% include "includes/export-as.html" %} @@ -46,7 +22,7 @@ {$ memberHelpers.renderProperties(doc.staticProperties, 'static-properties', 'static-property', 'Static properties') $} {$ memberHelpers.renderMethodDetails(versionInfo, doc.staticMethods, 'static-methods', 'static-method', 'Static methods') $} {$ memberHelpers.renderMethodDetails(versionInfo, doc.methods, 'instance-methods', 'instance-method', 'Methods') $} - {$ renderAncestorMembers(doc, 'methods') $} + {$ memberHelpers.renderDirectiveAncestors(doc, 'methods') $} {% endblock %} {% block endNotes %}{% endblock %} \ No newline at end of file diff --git a/aio/tools/transforms/templates/api/lib/memberHelpers.html b/aio/tools/transforms/templates/api/lib/memberHelpers.html index b984ed69c8..8a3367ef13 100644 --- a/aio/tools/transforms/templates/api/lib/memberHelpers.html +++ b/aio/tools/transforms/templates/api/lib/memberHelpers.html @@ -28,12 +28,15 @@ {%- endmacro -%} {%- macro renderMemberSyntax(member, truncateLines) -%} + {%- if member.boundTo %}@{$ member.boundTo.type $}( + {%- if member.boundTo.propertyName != member.boundTo.bindingName %}'{$ member.boundTo.bindingName $}'{% endif -%} + )
{% endif -%} {%- if member.accessibility !== 'public' %}{$ member.accessibility $} {% endif -%} {%- if member.isAbstract %}abstract {% endif -%} {%- if member.isStatic %}static {% endif -%} {%- if (member.isGetAccessor or member.isReadonly) and not member.isSetAccessor %}get {% endif -%} {%- if member.isSetAccessor and not member.isGetAccessor %}set {% endif -%} - {$ member.name $}{$ member.typeParameters | escape $}{% if not member.isGetAccessor %}{$ params.paramList(member.parameters, truncateLines) | trim $}{% endif %} + {$ member.name $}{$ member.typeParameters | escape $}{% if not member.isGetAccessor %}{$ params.paramList(member.parameters, truncateLines) | trim $}{% endif %} {%- if member.isOptional %}?{% endif -%} {$ params.returnType(member.type) | trim | truncateCode(truncateLines) $} {%- endmacro -%} @@ -184,9 +187,8 @@ {% for property in nonInternalProperties %} - {%- if property.boundTo %}@{$ property.boundTo.type $}({$ property.boundTo.bindingName $}) -{% endif -%}{$ property.name $}{% if property.type %}: {$ property.type | escape $}{% endif -%} - + + {$ renderMemberSyntax(property) $} {%- if (property.isGetAccessor or property.isReadonly) and not property.isSetAccessor %}Read-only.{% endif %} @@ -201,3 +203,27 @@ {%- endif -%} {%- endmacro -%} + +{% macro renderDirectiveAncestors(doc, collectionName) %} +{%- for ancestor in doc.extendsClauses %}{% if ancestor.doc %} +{% set nonInternalMembers = ancestor.doc[collectionName] | filterByPropertyValue('internal', undefined) %} +{% if nonInternalMembers.length -%} +
+

Inherited from {$ ancestor.doc.id $}

+ +
+{% endif %} +{$ renderDirectiveAncestors(ancestor.doc, collectionName) $} +{% endif %}{% endfor -%} +{% endmacro %} + +{% macro renderDirectiveProperties(doc, heading) %} +{$ renderProperties(doc.properties, 'instance-properties', 'instance-property', heading) $} +{$ renderDirectiveAncestors(doc, 'properties') $} +{% endmacro %}