build(docs-infra): include directives etc in class descendants lists (#25768)
PR Close #25768
This commit is contained in:
parent
ce06a75ebf
commit
15dadb92ef
|
@ -8,7 +8,19 @@ describe('Api pages', function() {
|
||||||
|
|
||||||
it('should show direct and indirect subclasses of a class', () => {
|
it('should show direct and indirect subclasses of a class', () => {
|
||||||
const page = new ApiPage('api/forms/AbstractControlDirective');
|
const page = new ApiPage('api/forms/AbstractControlDirective');
|
||||||
expect(page.getDescendants('class')).toEqual(['ControlContainer', 'AbstractFormGroupDirective', 'NgControl']);
|
expect(page.getDescendants('class')).toEqual([
|
||||||
|
'ControlContainer',
|
||||||
|
'AbstractFormGroupDirective',
|
||||||
|
'NgModelGroup',
|
||||||
|
'FormGroupName',
|
||||||
|
'NgForm',
|
||||||
|
'FormGroupDirective',
|
||||||
|
'FormArrayName',
|
||||||
|
'NgControl',
|
||||||
|
'NgModel',
|
||||||
|
'FormControlDirective',
|
||||||
|
'FormControlName'
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show child interfaces that extend an interface', () => {
|
it('should show child interfaces that extend an interface', () => {
|
||||||
|
|
|
@ -3,7 +3,12 @@ module.exports = function filterBy() {
|
||||||
name: 'filterByPropertyValue',
|
name: 'filterByPropertyValue',
|
||||||
process: function(list, property, value) {
|
process: function(list, property, value) {
|
||||||
if (!list) return list;
|
if (!list) return list;
|
||||||
return list.filter(item => item[property] === value);
|
const values = Array.isArray(value) ? value : [value];
|
||||||
|
return list.filter(item => values.some(value => compare(item[property], value)));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function compare(actual, expected) {
|
||||||
|
return expected instanceof(RegExp) ? expected.test(actual) : actual === expected;
|
||||||
|
}
|
|
@ -7,8 +7,19 @@ describe('filterByPropertyValue filter', () => {
|
||||||
|
|
||||||
it('should be called "filterByPropertyValue"', function() { expect(filter.name).toEqual('filterByPropertyValue'); });
|
it('should be called "filterByPropertyValue"', function() { expect(filter.name).toEqual('filterByPropertyValue'); });
|
||||||
|
|
||||||
it('should filter out items that do not match the given property value', function() {
|
it('should filter out items that do not match the given property string value', function() {
|
||||||
expect(filter.process([{ a: 1 }, { a: 2 }, { b: 1 }, { a: 1, b: 2 }, { a: null }, { a: undefined }], 'a', 1))
|
expect(filter.process([{ a: 1 }, { a: 2 }, { b: 1 }, { a: 1, b: 2 }, { a: null }, { a: undefined }], 'a', 1))
|
||||||
.toEqual([{ a: 1 }, { a: 1, b: 2 }]);
|
.toEqual([{ a: 1 }, { a: 1, b: 2 }]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it('should filter out items that do not match the given property regex value', function() {
|
||||||
|
expect(filter.process([{ a: '1' }, { a: '12' }, { b: '1' }, { a: 'a' }, { a: '1', b: '2' }, { a: null }, { a: undefined }], 'a', /\d/))
|
||||||
|
.toEqual([{ a: '1' }, { a: '12' }, { a: '1', b: '2' }]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should filter out items that do not match the given array of property regex/string values', function() {
|
||||||
|
expect(filter.process([{ a: '1' }, { a: '12' }, { b: '1' }, { a: 'a' }, { a: '1', b: '2' }, { a: null }, { a: undefined }], 'a', [/\d/, 'a']))
|
||||||
|
.toEqual([{ a: '1' }, { a: '12' }, { a: 'a' }, { a: '1', b: '2' }]);
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -6,5 +6,5 @@
|
||||||
{% if doc.isAbstract %}abstract {% endif%}class {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHeritage(doc) $} {{$ memberHelper.renderMembers(doc) $}
|
{% if doc.isAbstract %}abstract {% endif%}class {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHeritage(doc) $} {{$ memberHelper.renderMembers(doc) $}
|
||||||
}
|
}
|
||||||
</code-example>
|
</code-example>
|
||||||
{$ descendants.renderDescendants(doc, 'class', 'Subclasses') $}
|
{$ descendants.renderDescendants(doc, 'class', 'Subclasses', true, r/class|directive|pipe|decorator/) $}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -6,5 +6,5 @@ interface {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHerit
|
||||||
}
|
}
|
||||||
</code-example>
|
</code-example>
|
||||||
{$ descendants.renderDescendants(doc, 'interface', 'Child interfaces') $}
|
{$ descendants.renderDescendants(doc, 'interface', 'Child interfaces') $}
|
||||||
{$ descendants.renderDescendants(doc, 'class', 'Class implementations') $}
|
{$ descendants.renderDescendants(doc, 'class', 'Class implementations', true, r/class|directive|pipe|decorator/) $}
|
||||||
</section>
|
</section>
|
|
@ -1,22 +1,22 @@
|
||||||
{% macro renderDescendantList(descendants, docType, recursed) %}
|
{% macro renderDescendantList(descendants, descendantType, recursed, docTypeMatcher) %}
|
||||||
{% if descendants.length %}
|
{% if descendants.length %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for descendant in descendants %}
|
{% for descendant in descendants %}
|
||||||
<li>
|
<li>
|
||||||
<code>{$ descendant.name $}</code>
|
<code>{$ descendant.name $}</code>
|
||||||
{$ renderDescendantList(descendant.descendants | filterByPropertyValue('docType', docType), docType, recursed) $}
|
{$ renderDescendantList(descendant.descendants | filterByPropertyValue('docType', docTypeMatcher), docType, recursed, docTypeMatcher) $}
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro -%}
|
{% endmacro -%}
|
||||||
|
|
||||||
{%- macro renderDescendants(doc, docType, title='', recursed=true) %}
|
{%- macro renderDescendants(doc, descendantType, title='', recursed=true, docTypeMatcher=descendantType) %}
|
||||||
{% set descendants = doc.descendants | filterByPropertyValue('docType', docType) %}
|
{% set descendants = doc.descendants | filterByPropertyValue('docType', docTypeMatcher) %}
|
||||||
{% if descendants.length %}
|
{% if descendants.length %}
|
||||||
<div class="descendants {$ docType $}">
|
<div class="descendants {$ descendantType $}">
|
||||||
{% if title %}<h2>{$ title $}</h2>{% endif %}
|
{% if title %}<h2>{$ title $}</h2>{% endif %}
|
||||||
{$ renderDescendantList(descendants, docType, recursed) $}
|
{$ renderDescendantList(descendants, descendantType, recursed, docTypeMatcher) $}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
Loading…
Reference in New Issue