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,26 +106,29 @@
{% 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 $}">
<h2>{$ headingText $}</h2>
<table class="is-full-width list-table properties-table">
<thead> <thead>
<tr><th>Property</th><th>Type</th><th>Description</th></tr> <tr><th>Property</th><th>Type</th><th>Description</th></tr>
</thead> </thead>
<tbody> <tbody>
{% for property in properties %}{% if not property.internal %} {% for property in nonInternalProperties %}
<tr class="{$ propertyClass $}"> <tr class="{$ propertyClass $}">
<td><a id="{$ property.anchor $}"></a>{$ property.name $}</td> <td><a id="{$ property.anchor $}"></a>{$ property.name $}</td>
<td><label class="property-type-label"><code>{$ property.type | escape $}</code></label></td> <td><label class="property-type-label"><code>{$ property.type | escape $}</code></label></td>
@ -134,8 +137,9 @@
{% if property.constructorParamDoc %} <span class='from-constructor'>Declared in constructor.</span>{% endif %} {% if property.constructorParamDoc %} <span class='from-constructor'>Declared in constructor.</span>{% endif %}
</td> </td>
</tr> </tr>
{% endif %}{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</section>
{%- endif -%} {%- endif -%}
{%- endmacro -%} {%- endmacro -%}