Skip to content

Commit d426af7

Browse files
petebacondarwinnaomiblack
authored andcommitted
chore(doc-gen): trim leading blank lines from markdown content
Harp 0.17 does not allow blank lines to appear between filters and their content. This change ensures that any blank lines that could appear have been trimmed inside Nunkjucks. Closes angular#3325
1 parent 6ab2a87 commit d426af7

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

docs/angular.io-package/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,11 @@ module.exports = new Package('angular.io', [basePackage])
5454

5555
.config(function(getLinkInfo) {
5656
getLinkInfo.relativeLinks = true;
57-
});
57+
})
58+
59+
60+
.config(function(templateEngine, getInjectables) {
61+
templateEngine.filters = templateEngine.filters.concat(getInjectables([require('./rendering/trimBlankLines')]));
62+
});
63+
64+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = function(encodeCodeBlock) {
2+
return {
3+
name: 'trimBlankLines',
4+
process: function(str) {
5+
var lines = str.split(/\r?\n/);
6+
while(lines[0] === '') {
7+
lines.shift();
8+
}
9+
return lines.join('\n');
10+
}
11+
};
12+
};

docs/angular.io-package/templates/class.template.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
defined in {$ githubViewLink(doc) $}
99

1010
:markdown
11-
{$ doc.description | indent(2, true) $}
11+
{$ doc.description | indent(2, true) | trimBlankLines $}
1212

1313
{%- if doc.decorators %}
1414
.l-main-section
@@ -37,7 +37,7 @@
3737
{$ doc.constructorDoc.name $}{$ paramList(doc.constructorDoc.parameters) | indent(4, true) | trim $}
3838
{% endif %}
3939
:markdown
40-
{$ doc.constructorDoc.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') $}
40+
{$ doc.constructorDoc.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') | trimBlankLines $}
4141

4242

4343
{% endif -%}
@@ -52,8 +52,7 @@
5252
{$ member.name $}{$ paramList(member.parameters) | indent(4, true) | trim $}{$ returnType(doc.returnType) $}
5353
{% endif %}
5454
:markdown
55-
56-
{$ member.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') $}
55+
{$ member.description | indent(6, true) | replace('## Example', '') | replace('# Example', '') | trimBlankLines $}
5756

5857

5958

docs/angular.io-package/templates/function.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@
1717
defined in {$ githubViewLink(doc) $}
1818

1919
:markdown
20-
{$ doc.description | indent(4, true) $}
20+
{$ doc.description | indent(4, true) | trimBlankLines $}
2121

2222
{% endblock %}

docs/angular.io-package/templates/var.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
defined in {$ githubViewLink(doc) $}
1010

1111
:markdown
12-
{$ doc.description | indent(4, true) $}
12+
{$ doc.description | indent(4, true) | trimBlankLines $}
1313
{% endblock %}

0 commit comments

Comments
 (0)