diff --git a/aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.js b/aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.js new file mode 100644 index 0000000000..9070911625 --- /dev/null +++ b/aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.js @@ -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; + } + } + }; +}; \ No newline at end of file diff --git a/aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.spec.js b/aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.spec.js new file mode 100644 index 0000000000..c2ad68554f --- /dev/null +++ b/aio/tools/transforms/angular-base-package/rendering/truncateFirstLine.spec.js @@ -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...'); + }); +}); \ No newline at end of file diff --git a/aio/tools/transforms/templates/api/includes/class-overview.html b/aio/tools/transforms/templates/api/includes/class-overview.html index 08f50418bd..24b14d468d 100644 --- a/aio/tools/transforms/templates/api/includes/class-overview.html +++ b/aio/tools/transforms/templates/api/includes/class-overview.html @@ -5,9 +5,9 @@ {$ doc.docType $} {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHeritage(doc) $} { {%- if doc.statics.length %}{% for member in doc.statics %}{% if not member.internal %} - {$ memberHelper.renderMember(member) $}{% endif %}{% endfor %}{% endif %} + {$ memberHelper.renderMember(member, true) $}{% endif %}{% endfor %}{% endif %} {%- if doc.members.length %}{% for member in doc.members %}{% if not member.internal %} - {$ memberHelper.renderMember(member) $}{% endif %}{% endfor %}{% endif %} + {$ memberHelper.renderMember(member, true) $}{% endif %}{% endfor %}{% endif %} } diff --git a/aio/tools/transforms/templates/api/includes/interface-overview.html b/aio/tools/transforms/templates/api/includes/interface-overview.html index 1652d37fba..8b3199b7ac 100644 --- a/aio/tools/transforms/templates/api/includes/interface-overview.html +++ b/aio/tools/transforms/templates/api/includes/interface-overview.html @@ -4,7 +4,7 @@

Interface Overview

interface {$ doc.name $}{$ doc.typeParams | escape $}{$ memberHelper.renderHeritage(doc) $} { {% if doc.members.length %}{% for member in doc.members %}{% if not member.internal %} - {$ memberHelper.renderMember(member) $}{% endif %}{% endfor %}{% endif %} + {$ memberHelper.renderMember(member, true) $}{% endif %}{% endfor %}{% endif %} } \ 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 d180bc1ec3..5fcb26752a 100644 --- a/aio/tools/transforms/templates/api/lib/memberHelpers.html +++ b/aio/tools/transforms/templates/api/lib/memberHelpers.html @@ -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) -%} diff --git a/aio/tools/transforms/templates/api/lib/paramList.html b/aio/tools/transforms/templates/api/lib/paramList.html index f04063a824..d063dc2a91 100644 --- a/aio/tools/transforms/templates/api/lib/paramList.html +++ b/aio/tools/transforms/templates/api/lib/paramList.html @@ -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 -%}