Skip to content

Commit 254e331

Browse files
committed
Merge pull request #382 from documentationjs/ext-jsx-es6
Support js, jsx and es6 extensions by default
2 parents 45b7b50 + f830027 commit 254e331

File tree

8 files changed

+116
-8
lines changed

8 files changed

+116
-8
lines changed

lib/filter_js.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function filterJS(extensions) {
2020
if (typeof extensions === 'string') {
2121
extensions = [extensions];
2222
}
23-
extensions = extensions.concat('js');
23+
extensions = extensions.concat(['js', 'es6', 'jsx']);
2424

2525
return function (data) {
2626
return extensions.indexOf(path.extname(data.file).substring(1)) !== -1;

test/bin.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ test('external modules option', function (t) {
9898
});
9999

100100
test('extension option', function (t) {
101-
documentation(['build fixture/extension/jsx.jsx ' +
102-
'--extension=jsx'], function (err, data) {
101+
documentation(['build fixture/extension/index.otherextension ' +
102+
'--extension=otherextension'], function (err, data) {
103103
t.ifError(err);
104-
t.equal(data.length, 1, 'includes jsx file');
104+
t.equal(data.length, 1, 'includes a file with an arbitrary extension');
105105
t.end();
106106
});
107107
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* apples
3+
*/
4+
function apples() {}
5+
6+
var HelloMessage = React.createClass({
7+
render: function() {
8+
return <div>Hello {this.props.name}</div>;
9+
}
10+
});
11+
12+
ReactDOM.render(<HelloMessage name="John" />, mountNode);

test/fixture/extension/jsx.jsx

Lines changed: 0 additions & 4 deletions
This file was deleted.

test/fixture/react-jsx.input.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* apples
3+
*/
4+
function apples() {}
5+
6+
var HelloMessage = React.createClass({
7+
render: function() {
8+
return <div>Hello {this.props.name}</div>;
9+
}
10+
});
11+
12+
ReactDOM.render(<HelloMessage name="John" />, mountNode);

test/fixture/react-jsx.output.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[
2+
{
3+
"description": "apples",
4+
"tags": [],
5+
"loc": {
6+
"start": {
7+
"line": 1,
8+
"column": 0
9+
},
10+
"end": {
11+
"line": 3,
12+
"column": 3
13+
}
14+
},
15+
"context": {
16+
"loc": {
17+
"start": {
18+
"line": 4,
19+
"column": 0
20+
},
21+
"end": {
22+
"line": 4,
23+
"column": 20
24+
}
25+
},
26+
"code": "/**\n * apples\n */\nfunction apples() {}\n\nvar HelloMessage = React.createClass({\n render: function() {\n return <div>Hello {this.props.name}</div>;\n }\n});\n\nReactDOM.render(<HelloMessage name=\"John\" />, mountNode);\n"
27+
},
28+
"errors": [],
29+
"name": "apples",
30+
"kind": "function",
31+
"members": {
32+
"instance": [],
33+
"static": []
34+
},
35+
"path": [
36+
"apples"
37+
]
38+
}
39+
]

test/fixture/react-jsx.output.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# apples
2+
3+
apples

test/fixture/react-jsx.output.md.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"type": "root",
3+
"children": [
4+
{
5+
"depth": 1,
6+
"type": "heading",
7+
"children": [
8+
{
9+
"type": "text",
10+
"value": "apples"
11+
}
12+
]
13+
},
14+
{
15+
"type": "paragraph",
16+
"children": [
17+
{
18+
"type": "text",
19+
"value": "apples",
20+
"position": {
21+
"start": {
22+
"line": 1,
23+
"column": 1
24+
},
25+
"end": {
26+
"line": 1,
27+
"column": 7
28+
},
29+
"indent": []
30+
}
31+
}
32+
],
33+
"position": {
34+
"start": {
35+
"line": 1,
36+
"column": 1
37+
},
38+
"end": {
39+
"line": 1,
40+
"column": 7
41+
},
42+
"indent": []
43+
}
44+
}
45+
]
46+
}

0 commit comments

Comments
 (0)