fix(aio): do not show Properties/Methods sections if only internal members (#22471)

PR Close #22471
This commit is contained in:
George Kalpakas 2018-02-27 11:07:29 +02:00 committed by Alex Eagle
parent 79656e7f96
commit 142117f6bb
3 changed files with 40 additions and 22 deletions

View File

@ -40,4 +40,14 @@ describe('Api pages', function() {
const page = new ApiPage('api/common/HashLocationStrategy'); const page = new ApiPage('api/common/HashLocationStrategy');
expect(page.getOverview('class').getText()).toContain('path(includeHash: boolean = false): string'); expect(page.getOverview('class').getText()).toContain('path(includeHash: boolean = false): string');
}); });
it('should show a "Properties" section if there are public properties', () => {
const page = new ApiPage('api/core/ViewContainerRef');
expect(page.getSection('instance-properties').isPresent()).toBe(true);
});
it('should not show a "Properties" section if there are only internal properties', () => {
const page = new ApiPage('api/forms/FormControl');
expect(page.getSection('instance-properties').isPresent()).toBe(false);
});
}); });

View File

@ -31,4 +31,8 @@ export class ApiPage extends SitePage {
getOverview(docType) { getOverview(docType) {
return element(by.css(`.${docType}-overview`)); return element(by.css(`.${docType}-overview`));
} }
getSection(cls) {
return element(by.css(`section.${cls}`));
}
} }

View File

@ -106,36 +106,40 @@
{% endmacro -%} {% endmacro -%}
{%- macro renderMethodDetails(methods, containerClass, itemClass, headingText) -%} {%- macro renderMethodDetails(methods, containerClass, itemClass, headingText) -%}
{% if methods.length %} {% set nonInternalMethods = methods | filterByPropertyValue('internal', undefined) %}
{% if nonInternalMethods.length %}
<section class="{$ containerClass $}"> <section class="{$ containerClass $}">
<h2>{$ headingText $}</h2> <h2>{$ headingText $}</h2>
{% for member in methods %}{% if not member.internal %} {% for member in nonInternalMethods %}
{$ renderMethodDetail(member, itemClass) $} {$ renderMethodDetail(member, itemClass) $}
{% endif %}{% endfor %} {% endfor %}
</section> </section>
{% endif %} {% endif %}
{%- endmacro -%} {%- endmacro -%}
{%- macro renderProperties(properties, containerClass, propertyClass, headingText) -%} {%- macro renderProperties(properties, containerClass, propertyClass, headingText) -%}
{%- if properties.length -%} {% set nonInternalProperties = properties | filterByPropertyValue('internal', undefined) %}
<h2>{$ headingText $}</h2> {% if nonInternalProperties.length -%}
<table class="is-full-width list-table properties-table"> <section class="{$ containerClass $}">
<thead> <h2>{$ headingText $}</h2>
<tr><th>Property</th><th>Type</th><th>Description</th></tr> <table class="is-full-width list-table properties-table">
</thead> <thead>
<tbody> <tr><th>Property</th><th>Type</th><th>Description</th></tr>
{% for property in properties %}{% if not property.internal %} </thead>
<tr class="{$ propertyClass $}"> <tbody>
<td><a id="{$ property.anchor $}"></a>{$ property.name $}</td> {% for property in nonInternalProperties %}
<td><label class="property-type-label"><code>{$ property.type | escape $}</code></label></td> <tr class="{$ propertyClass $}">
<td> <td><a id="{$ property.anchor $}"></a>{$ property.name $}</td>
{$ (property.description or property.constructorParamDoc.description) | marked $} <td><label class="property-type-label"><code>{$ property.type | escape $}</code></label></td>
{% if property.constructorParamDoc %} <span class='from-constructor'>Declared in constructor.</span>{% endif %} <td>
</td> {$ (property.description or property.constructorParamDoc.description) | marked $}
</tr> {% if property.constructorParamDoc %} <span class='from-constructor'>Declared in constructor.</span>{% endif %}
{% endif %}{% endfor %} </td>
</tbody> </tr>
</table> {% endfor %}
</tbody>
</table>
</section>
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}