Fix for extra chars with explicit #docplaster in css and html files. + additional test cases.

This commit is contained in:
Jay Traband 2015-10-20 16:51:36 -07:00 committed by Naomi Black
parent 3b76748cb5
commit 58b8242a25
14 changed files with 124 additions and 2 deletions

View File

@ -30,8 +30,8 @@ describe('doc-shredder', function() {
fileNames.forEach(function(fileName) {
console.log('comparing: ' + fileName);
var origFileName = fileName.replace('.ovr.', '.');
var origSource = fs.readFileSync(origFileName, 'utf8');
var expectedSource = fs.readFileSync(fileName, 'utf8');
var origSource = fs.readFileSync(origFileName, 'utf8').replace(/\r\n/g, '\n');
var expectedSource = fs.readFileSync(fileName, 'utf8').replace(/\r\n/g, '\n');
var diffs = JsDiff.diffLines(expectedSource, origSource);
errs = [];
diffs.forEach(function(diff) {

View File

@ -0,0 +1,3 @@
```
import {Component, View, bootstrap} from 'angular2/angular2';
```

View File

@ -0,0 +1,6 @@
```
import {Component, View, bootstrap} from 'angular2/angular2';
// indented comment
var x = 3;
// final comment
```

View File

@ -0,0 +1,11 @@
```
name: angular2-getting-started
version: 0.0.1
dependencies:
angular2: ^2.0.0-alpha.41
browser: ^0.10.0
transformers:
- angular2:
entry_points: web/main.dart
```

View File

@ -0,0 +1,6 @@
```
name: angular2-getting-started
# special plaster
angular2: ^2.0.0-alpha.41
browser: ^0.10.0
```

View File

@ -0,0 +1,12 @@
```
<html>
<head>
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.sfx.dev.js"></script>
<script src="main.js"></script>
</head>
<body>
<my-app></my-app>
</body>
</html>
```

View File

@ -0,0 +1,7 @@
```
<html>
<!-- special plaster -->
<body>
<my-app></my-app>
</body>
```

View File

@ -0,0 +1,6 @@
```
h2 { color: #444; font-weight: lighter; }
body { margin: 2em; }
/* plaster here */
body, input[text], button { color: #888; font-family: Cambria, Georgia; }
```

View File

@ -0,0 +1,6 @@
```
h2 { color: #444; font-weight: lighter; }
/* plaster here */
body, input[text], button { color: #888; font-family: Cambria, Georgia; }
button {padding: 0.2em; font-size: 14px}
```

View File

@ -0,0 +1,26 @@
// no docplaster
// #docplaster
// #docregion import,twoparts
import {Component, View, bootstrap} from 'angular2/angular2';
// #enddocregion twoparts, import
@Component({
selector: 'my-app'
})
@View({
template: '<h1 id="output">My first Angular 2 App</h1>'
})
class AppComponent {
}
// #docregion twoparts
// indented comment
var x = 3;
// #enddocregion
bootstrap(AppComponent);
// #docregion twoparts
// final comment
// #enddocregion twoparts

View File

@ -0,0 +1,13 @@
# #docplaster special plaster
# #docregion foo, bar
name: angular2-getting-started
# #enddocregion foo
version: 0.0.1
dependencies:
# #docregion foo
angular2: ^2.0.0-alpha.41
browser: ^0.10.0
# #enddocregion foo
transformers:
- angular2:
entry_points: web/main.dart

View File

@ -0,0 +1,15 @@
<!-- #docplaster special plaster -->
<!DOCTYPE html>
<!-- #docregion bar, foo -->
<html>
<!-- #enddocregion foo -->
<head>
<script src="https://code.angularjs.org/2.0.0-alpha.26/angular2.sfx.dev.js"></script>
<script src="main.js"></script>
</head>
<!-- #docregion foo -->
<body>
<my-app></my-app>
</body>
<!-- #enddocregion foo -->
</html>

View File

@ -0,0 +1,10 @@
/* #docplaster plaster here */
/* #docregion foo, bar */
h2 { color: #444; font-weight: lighter; }
/* #enddocregion foo
body { margin: 2em; }
/* #enddocregion bar
/* #docregion foo, bar */
body, input[text], button { color: #888; font-family: Cambria, Georgia; }
/* #enddocregion bar
button {padding: 0.2em; font-size: 14px}

View File

@ -218,6 +218,7 @@ function getDocPlaster(line) {
var rx = /#docplaster\s*(\S.*)/;
try {
var plaster = line.match(rx)[1];
plaster = plaster.replace("-->","").replace('\*\/',"");
return plaster.trim();
} catch (e) {
return null;