Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ node_js:
- '0.10'
- '0.12'
- '4.2'
- '6'
- '8'
- 'lts/*'
- 'stable'

sudo: false
Expand Down
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,21 @@ var filterAndGroup = function (lines) {
var group = false

lines.forEach(function (line) {
var isAnnotation = line.indexOf('@') === 0
var trimmedLine = line.trim()
var isAnnotation = trimmedLine.indexOf('@') === 0

if (line.trim().indexOf('---') !== 0) { // Ignore lines that start with "---"
if (trimmedLine.indexOf('---') !== 0) { // Ignore lines that start with "---"
if (group) {
if (isAnnotation) {
nLines.push(line)
nLines.push(trimmedLine)
} else {
nLines[nLines.length - 1] += '\n' + line
}
} else if (isAnnotation) {
group = true
nLines.push(line)
nLines.push(trimmedLine)
} else {
nLines.push(line)
nLines.push(trimmedLine)
}
}
})
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/annotation.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// Description
/// @test Test
.foo {
font-weight: bold;
}
9 changes: 9 additions & 0 deletions test/fixtures/indentedAnnotation.test.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$foo: true;

@if ($foo) {
/// Description
/// @test Test
.foo {
font-weight: bold;
}
}
21 changes: 19 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('scss-comment-parser', function () {
})

describe('unknown', function () {
it('should assing unknown', function () {
it('should assign unknown', function () {
var context = parser.contextParser(getContent('unknown.test.scss'))
assert.deepEqual(context, {
type: 'unknown'
Expand All @@ -183,7 +183,12 @@ describe('scss-comment-parser', function () {
var parser

beforeEach(function () {
parser = new ScssCommentParser({})
parser = new ScssCommentParser({
_: { alias: {} },
test: {
parse: function(content) { return content.toString() }
}
})
})

describe('group by type', function () {
Expand Down Expand Up @@ -221,6 +226,18 @@ describe('scss-comment-parser', function () {
}
})
})

it('should parse annotations', function () {
var result = parser.parse(getContent('annotation.test.scss'))
assert.equal(result[0].description, 'Description\n')
assert.equal(result[0].test, 'Test')
})

it('should parse indented annotations', function () {
var result = parser.parse(getContent('indentedAnnotation.test.scss'))
assert.equal(result[0].description, 'Description\n')
assert.equal(result[0].test, 'Test')
})
})

describe('#extractCode', function () {
Expand Down