From 713a428bb643bbc088c5bc138a26536eeaec48ad Mon Sep 17 00:00:00 2001 From: Jay Traband Date: Mon, 10 Aug 2015 20:41:59 -0700 Subject: [PATCH] Fix for triply or greater nested fragments and trailing nullLine markers --- public/doc-shredder/regionExtractor.js | 9 +++++--- public/doc-shredder/test/test_source/app2.ts | 22 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 public/doc-shredder/test/test_source/app2.ts 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/public/doc-shredder/test/test_source/app2.ts b/public/doc-shredder/test/test_source/app2.ts new file mode 100644 index 0000000000..336b35219e --- /dev/null +++ b/public/doc-shredder/test/test_source/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