From 5b2c6dc262be7026d47699feee3e0d91b9f24f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Knezi=C4=87?= Date: Tue, 1 Nov 2016 15:30:10 +0100 Subject: [PATCH 01/13] Fix annotation parsing in nested comment blocks --- index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 50bc711..670e850 100644 --- a/index.js +++ b/index.js @@ -170,24 +170,25 @@ var scssContextParser = (function () { })() var filterAndGroup = function (lines) { - var nLines = [] - var group = false + var nLines = []; + var group = false; lines.forEach(function (line) { - var isAnnotation = line.indexOf('@') === 0 - - if (line.trim().indexOf('---') !== 0) { // Ignore lines that start with "---" + var trimmedLine = line.trim(); + var isAnnotation = trimmedLine.indexOf('@') === 0; + + if (trimmedLine.trim().indexOf('---') !== 0) { // Ignore lines that start with "---" if (group) { if (isAnnotation) { - nLines.push(line) + nLines.push(trimmedLine); } else { - nLines[nLines.length - 1] += '\n' + line + nLines[nLines.length - 1] += '\n' + line; } } else if (isAnnotation) { - group = true - nLines.push(line) + group = true; + nLines.push(trimmedLine); } else { - nLines.push(line) + nLines.push(trimmedLine); } } }) From 3690b6d4225e81657edc3140aa9a6871c5e16c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Knezi=C4=87?= Date: Tue, 1 Nov 2016 15:55:33 +0100 Subject: [PATCH 02/13] Don't trim line twice in filterAndGroup function --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 670e850..f34bc5b 100644 --- a/index.js +++ b/index.js @@ -177,7 +177,7 @@ var filterAndGroup = function (lines) { var trimmedLine = line.trim(); var isAnnotation = trimmedLine.indexOf('@') === 0; - if (trimmedLine.trim().indexOf('---') !== 0) { // Ignore lines that start with "---" + if (trimmedLine.indexOf('---') !== 0) { // Ignore lines that start with "---" if (group) { if (isAnnotation) { nLines.push(trimmedLine); From ecb8598a3a0690c9d8e36dae77cad0dad7376f44 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 11:56:02 +0200 Subject: [PATCH 03/13] Unify code styling --- index.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f34bc5b..2249ab2 100644 --- a/index.js +++ b/index.js @@ -170,25 +170,25 @@ var scssContextParser = (function () { })() var filterAndGroup = function (lines) { - var nLines = []; - var group = false; + var nLines = [] + var group = false lines.forEach(function (line) { var trimmedLine = line.trim(); var isAnnotation = trimmedLine.indexOf('@') === 0; - + if (trimmedLine.indexOf('---') !== 0) { // Ignore lines that start with "---" if (group) { if (isAnnotation) { nLines.push(trimmedLine); } else { - nLines[nLines.length - 1] += '\n' + line; + nLines[nLines.length - 1] += '\n' + line } } else if (isAnnotation) { - group = true; - nLines.push(trimmedLine); + group = true + nLines.push(trimmedLine) } else { - nLines.push(trimmedLine); + nLines.push(trimmedLine) } } }) From 7160107c6055813de688eb40ae5afaaf9ccfd768 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 12:24:12 +0200 Subject: [PATCH 04/13] Add unit test for annotations on nested blocks --- test/fixtures/annotationsNestedBlock.test.scss | 5 +++++ test/test.js | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/fixtures/annotationsNestedBlock.test.scss diff --git a/test/fixtures/annotationsNestedBlock.test.scss b/test/fixtures/annotationsNestedBlock.test.scss new file mode 100644 index 0000000..7b235c2 --- /dev/null +++ b/test/fixtures/annotationsNestedBlock.test.scss @@ -0,0 +1,5 @@ +.foo { + /// Test description + /// @test TestType + $test-variable: blue; +} \ No newline at end of file diff --git a/test/test.js b/test/test.js index b78edf2..d8468cf 100644 --- a/test/test.js +++ b/test/test.js @@ -201,6 +201,22 @@ describe('scss-comment-parser', function () { }) }) + it('should parse annotations on a nested block', function () { + var annotationName = 'test'; + var annotations = { + _: { alias: { annotationName } }, + [annotationName]: { + name: annotationName, + parse: (text) => text, + } + } + + var result = new ScssCommentParser(annotations).parse(getContent('annotationsNestedBlock.test.scss')); + assert.equal(result.length, 1); + assert.equal(result[0].description, 'Test description\n'); + assert.equal(result[0][annotationName], 'TestType'); + }) + it('should ignore lines that start with "---"', function () { var result = parser.parse(getContent('ignoreLine.test.scss')) assert.equal(result.length, 1) From dd6773650f0d9a7d5336c7129857902bf7a2304d Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 12:34:24 +0200 Subject: [PATCH 05/13] Fix annotations object on test --- test/test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index d8468cf..ceb3ab5 100644 --- a/test/test.js +++ b/test/test.js @@ -204,10 +204,16 @@ describe('scss-comment-parser', function () { it('should parse annotations on a nested block', function () { var annotationName = 'test'; var annotations = { - _: { alias: { annotationName } }, + _: { + alias: { + [annotationName]: annotationName + } + }, [annotationName]: { name: annotationName, - parse: (text) => text, + parse (text) { + return text + }, } } From dec4838e83e8fa21046a0003a7d94e658196838d Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 12:36:29 +0200 Subject: [PATCH 06/13] Fix annotations object on test (2) --- test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index ceb3ab5..a844734 100644 --- a/test/test.js +++ b/test/test.js @@ -206,10 +206,10 @@ describe('scss-comment-parser', function () { var annotations = { _: { alias: { - [annotationName]: annotationName + 'test': annotationName } }, - [annotationName]: { + 'test': { name: annotationName, parse (text) { return text From a45f87196d718362acc09a19ebc82023856b3cb3 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 12:39:26 +0200 Subject: [PATCH 07/13] Fix annotations object on test (3) --- test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.js b/test/test.js index a844734..27aa02e 100644 --- a/test/test.js +++ b/test/test.js @@ -211,7 +211,7 @@ describe('scss-comment-parser', function () { }, 'test': { name: annotationName, - parse (text) { + parse: function (text) { return text }, } From 1efc0994bb83d7aa7a29e301c31148036aa76ae9 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 12:54:19 +0200 Subject: [PATCH 08/13] Fix lint issues --- index.js | 6 +++--- test/test.js | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 2249ab2..2ca02b3 100644 --- a/index.js +++ b/index.js @@ -174,13 +174,13 @@ var filterAndGroup = function (lines) { var group = false lines.forEach(function (line) { - var trimmedLine = line.trim(); - var isAnnotation = trimmedLine.indexOf('@') === 0; + var trimmedLine = line.trim() + var isAnnotation = trimmedLine.indexOf('@') === 0 if (trimmedLine.indexOf('---') !== 0) { // Ignore lines that start with "---" if (group) { if (isAnnotation) { - nLines.push(trimmedLine); + nLines.push(trimmedLine) } else { nLines[nLines.length - 1] += '\n' + line } diff --git a/test/test.js b/test/test.js index 27aa02e..3b62e0f 100644 --- a/test/test.js +++ b/test/test.js @@ -202,7 +202,7 @@ describe('scss-comment-parser', function () { }) it('should parse annotations on a nested block', function () { - var annotationName = 'test'; + var annotationName = 'test' var annotations = { _: { alias: { @@ -213,14 +213,14 @@ describe('scss-comment-parser', function () { name: annotationName, parse: function (text) { return text - }, + } } } - var result = new ScssCommentParser(annotations).parse(getContent('annotationsNestedBlock.test.scss')); - assert.equal(result.length, 1); - assert.equal(result[0].description, 'Test description\n'); - assert.equal(result[0][annotationName], 'TestType'); + var result = new ScssCommentParser(annotations).parse(getContent('annotationsNestedBlock.test.scss')) + assert.equal(result.length, 1) + assert.equal(result[0].description, 'Test description\n') + assert.equal(result[0][annotationName], 'TestType') }) it('should ignore lines that start with "---"', function () { From 18e45cc7b94f3716378523e1b62763f08a1d4157 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 13:02:55 +0200 Subject: [PATCH 09/13] Update compilers versions --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d7cdecc..06c4244 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ node_js: - '4.2' - 'stable' +env: + - CXX=g++-4.8 + sudo: false git: From 67c00202af6f7d501912fe0de1ba2f2c11a30a4c Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 13:20:43 +0200 Subject: [PATCH 10/13] Revert "Update compilers versions" This reverts commit 18e45cc7b94f3716378523e1b62763f08a1d4157. --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 06c4244..d7cdecc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,6 @@ node_js: - '4.2' - 'stable' -env: - - CXX=g++-4.8 - sudo: false git: From 68b142554707fc470451a3410ec8cb1708f604df Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 13:21:17 +0200 Subject: [PATCH 11/13] Remove node version 4.2 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7cdecc..4195b41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: node_js node_js: - '0.10' - '0.12' - - '4.2' - 'stable' sudo: false From 35c815876af9133d7d36852edf52254046f1102c Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 13:29:47 +0200 Subject: [PATCH 12/13] Update compilers versions (2) --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4195b41..edd35eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,19 @@ language: node_js node_js: - '0.10' - '0.12' + - '4.2' - 'stable' sudo: false +env: + - CXX=g++-4.8 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + git: depth: 10 From 074c340865303f033a23cdce4f8eb21f051c53e4 Mon Sep 17 00:00:00 2001 From: Ruggero Cino Date: Thu, 23 Jul 2020 15:18:30 +0200 Subject: [PATCH 13/13] Remove compiler version and node 4.2 version --- .travis.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index edd35eb..4195b41 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,19 +3,9 @@ language: node_js node_js: - '0.10' - '0.12' - - '4.2' - 'stable' sudo: false -env: - - CXX=g++-4.8 -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 - git: depth: 10