diff --git a/public/doc-shredder/regionExtractor.js b/public/doc-shredder/regionExtractor.js index 2fe6c433a7..8941667a96 100644 --- a/public/doc-shredder/regionExtractor.js +++ b/public/doc-shredder/regionExtractor.js @@ -17,10 +17,10 @@ module.exports = function regionExtractor() { lines.forEach(function(line, ix) { if (isCommentLine(line, commentPrefixes)) { if (hasRegionTag(line)) { + if (doc) docStack.push(doc); doc = {startIx: ix, regionName: getRegionName(line)}; lines[ix] = nullLine; docs.push(doc); - docStack.push(doc); } else if (hasEndRegionTag(line)) { lines[ix] = nullLine; doc.endIx = ix; @@ -38,8 +38,11 @@ module.exports = function regionExtractor() { } // eliminate all #docregion lines var rx = new RegExp(nullLine + '\n', 'g'); - doc.content = content.replace(rx, ''); - + var content = content.replace(rx, ''); + if (content.substr(-3) === nullLine) { + content = content.substr(0, content.length-3); + } + doc.content = content; }); return docs; } diff --git a/tools/doc-shredder/_test/test_source/no-multiregion/app2.ts b/tools/doc-shredder/_test/test_source/no-multiregion/app2.ts new file mode 100644 index 0000000000..336b35219e --- /dev/null +++ b/tools/doc-shredder/_test/test_source/no-multiregion/app2.ts @@ -0,0 +1,22 @@ +// #docregion +// #docregion import +import {Component, View, bootstrap} from 'angular2/angular2'; +// #enddocregion + +//#docregion class-w-annotations +@Component({ + selector: 'my-app' +}) +@View({ + template: '

Hello, Angular 2!

' +}) +//#docregion class +class MyAppComponent { +} +//#enddocregion +//#enddocregion + +//#docregion bootstrap +bootstrap(MyAppComponent); +//#enddocregion +//#enddocregion