Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/annotation/annotations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = [
require('./group.js'),
require('./ignore.js'),
require('./link.js'),
require('./name.js'),
require('./output.js'),
require('./parameter.js'),
require('./property.js'),
Expand Down
20 changes: 20 additions & 0 deletions src/annotation/annotations/name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export default function access() {
return {
name: 'name',

parse(text) {
return text.trim();
},

// Abuse the autofill feature to rewrite the `item.context`
autofill(item){
Copy link
Member

Choose a reason for hiding this comment

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

Missing space before brace.

if (item.name) {
item.context.name = item.name;
// Cleanup
delete item.name;
}
},

multiple: false
};
}
14 changes: 14 additions & 0 deletions test/annotations/name.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

var assert = require('assert');

describe('#name', function () {
var name = (new (require('../../dist/annotation'))()).list.name;

it('should return the trimmed string', function () {
assert.equal(name.parse(' '), '');
assert.equal(name.parse(' '), '');
assert.equal(name.parse('\ntest\t'), 'test');
assert.equal(name.parse('\nte\nst\t'), 'te\nst');
});
});
24 changes: 24 additions & 0 deletions test/data/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -600,5 +600,29 @@
"path": "test.scss",
"name": "test.scss"
}
},
{
"description": "This is a test placeholder aiming at testing:\n- `@name`\n",
"commentRange": {
"start": 175,
"end": 177
},
"context": {
"type": "placeholder",
"name": "placeholder-[blue,green,red]",
"code": "",
"line": {
"start": 179,
"end": 179
}
},
"group": [
"test"
],
"access": "private",
"file": {
"path": "test.scss",
"name": "test.scss"
}
}
]
6 changes: 6 additions & 0 deletions test/data/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,9 @@ $variable-specific-test: ();
/// @alias should-warn

@function alias-test-should-warn() {}

/// This is a test placeholder aiming at testing:
/// - `@name`
/// @name placeholder-[blue,green,red]

%placeholder-#{$color} {}