build(aio): truncate API overview parameters at one line
This commit is contained in:
parent
a7ea0086ee
commit
998049ec9b
|
@ -0,0 +1,13 @@
|
|||
module.exports = function() {
|
||||
return {
|
||||
name: 'truncateFirstLine',
|
||||
process: function(str) {
|
||||
const parts = str && str.split && str.split(/\r?\n/);
|
||||
if (parts && parts.length > 1) {
|
||||
return parts[0] + '...';
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
var factory = require('./truncateFirstLine');
|
||||
|
||||
describe('truncateFirstLine filter', function() {
|
||||
var filter;
|
||||
|
||||
beforeEach(function() { filter = factory(); });
|
||||
|
||||
it('should be called "truncateFirstLine"',
|
||||
function() { expect(filter.name).toEqual('truncateFirstLine'); });
|
||||
|
||||
it('should return the whole string if only one line', function() {
|
||||
expect(filter.process('this is a pretty long string that only exists on one line'))
|
||||
.toEqual('this is a pretty long string that only exists on one line');
|
||||
});
|
||||
|
||||
it('should return the first line and an ellipsis if there is more than one line', function() {
|
||||
expect(filter.process('some text\n \nmore text\n \n')).toEqual('some text...');
|
||||
});
|
||||
});
|
|
@ -5,9 +5,9 @@
|
|||
<code-example language="ts" hideCopy="true">
|
||||
{$ doc.docType $} {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHeritage(doc) $} {
|
||||
{%- if doc.statics.length %}{% for member in doc.statics %}{% if not member.internal %}
|
||||
<a class="code-anchor" href="#{$ member.anchor $}">{$ memberHelper.renderMember(member) $}</a>{% endif %}{% endfor %}{% endif %}
|
||||
<a class="code-anchor" href="#{$ member.anchor $}">{$ memberHelper.renderMember(member, true) $}</a>{% endif %}{% endfor %}{% endif %}
|
||||
{%- if doc.members.length %}{% for member in doc.members %}{% if not member.internal %}
|
||||
<a class="code-anchor" href="#{$ member.anchor $}">{$ memberHelper.renderMember(member) $}</a>{% endif %}{% endfor %}{% endif %}
|
||||
<a class="code-anchor" href="#{$ member.anchor $}">{$ memberHelper.renderMember(member, true) $}</a>{% endif %}{% endfor %}{% endif %}
|
||||
}
|
||||
</code-example>
|
||||
</section>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<h2>Interface Overview</h2>
|
||||
<code-example language="ts" hideCopy="true">
|
||||
interface {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHeritage(doc) $} { {% if doc.members.length %}{% for member in doc.members %}{% if not member.internal %}
|
||||
<a class="code-anchor" href="#{$ member.anchor $}">{$ memberHelper.renderMember(member) $}</a>{% endif %}{% endfor %}{% endif %}
|
||||
<a class="code-anchor" href="#{$ member.anchor $}">{$ memberHelper.renderMember(member, true) $}</a>{% endif %}{% endfor %}{% endif %}
|
||||
}
|
||||
</code-example>
|
||||
</section>
|
|
@ -9,14 +9,14 @@
|
|||
{% endfor %}{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro renderMember(member) -%}
|
||||
{%- macro renderMember(member, truncate) -%}
|
||||
{%- if member.accessibility !== 'public' %}{$ member.accessibility $} {% endif -%}
|
||||
{%- if member.isGetAccessor %}get {% endif -%}
|
||||
{%- if member.isSetAccessor %}set {% endif -%}
|
||||
{%- if member.isStatic %}static {% endif -%}
|
||||
{$ member.name $}{$ member.typeParameters | escape $}{$ params.paramList(member.parameters) | trim $}
|
||||
{$ member.name $}{$ member.typeParameters | escape $}{$ params.paramList(member.parameters, truncate) | trim $}
|
||||
{%- if member.isOptional %}?{% endif -%}
|
||||
{$ params.returnType(member.type) $}
|
||||
{$ params.returnType(member.type) | trim | truncateFirstLine $}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro renderMemberDetail(member, cssClass) -%}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% macro paramList(params) -%}
|
||||
{% macro paramList(params, truncate) -%}
|
||||
{%- if params -%}
|
||||
({%- for param in params -%}
|
||||
{$ param | escape $}{% if not loop.last %}, {% endif %}
|
||||
{% if truncate %}{$ param | escape | truncateFirstLine $}{% else %}{$ param | escape $}{% endif %}{% if not loop.last %}, {% endif %}
|
||||
{%- endfor %})
|
||||
{%- endif %}
|
||||
{%- endmacro -%}
|
||||
|
|
Loading…
Reference in New Issue