Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 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
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: node_js

node_js:
- '0.10'
- '0.12'
- '4.2'
- 'stable'
- 6
- 8
- lts/*

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add 6, 8, lts/*, leave the rest untouched, we will remove old node support in the next major, but until then this would be a breaking change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reapplied those versions, but seems to be an issue with the 4.2 pipleline job - https://travis-ci.org/SassDoc/scss-comment-parser/jobs/528927921

Can't see it being related to the changes in the PR, can't even get yarn to run using that version locally.

Worth trying 4.8 that's mentioned in the warning? Same major version so shouldn't be considered breaking?

- 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