Skip to content

Commit 131628e

Browse files
committed
Test Markdown meta support
1 parent 9b65a08 commit 131628e

File tree

6 files changed

+579
-1
lines changed

6 files changed

+579
-1
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494
"doc": "./bin/documentation.js build index.js -f md --access=public > docs/NODE_API.md",
9595
"changelog": "standard-changelog -i CHANGELOG.md -w",
9696
"self-lint": "node ./bin/documentation.js lint",
97-
"test": "are-we-flow-yet lib && flow check && npm run lint && npm run self-lint && tap -t 120 --coverage --nyc-arg=--cache test/*.js test/lib test/streams"
97+
"test": "are-we-flow-yet lib && flow check && npm run lint && npm run self-lint && npm run test-tap",
98+
"test-tap": "tap -t 120 --coverage --nyc-arg=--cache test/*.js test/lib test/streams"
9899
},
99100
"config": {
100101
"commitizen": {

test/bin-readme.js

+10
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ test('readme command', function (group) {
9292
});
9393
});
9494

95+
group.test('-s: not found', function (t) {
96+
t.error(err);
97+
fs.copySync(path.join(fixtures, 'README.output.md'), path.join(d, 'uptodate.md'));
98+
documentation(['readme index.js --diff-only -s NOTFOUND --readme-file uptodate.md'],
99+
{cwd: d}, function (err, stdout, stderr) {
100+
t.ok(err);
101+
t.end();
102+
});
103+
});
104+
95105
group.test('requires -s option', function (t) {
96106
documentation(['readme index.js'], {cwd: d}, function (err, stdout, stderr) {
97107
t.ok(err);

test/fixture/meta.input.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* This function returns the number one.
3+
* @returns {number} numberone
4+
* @version 1.0.0
5+
* @since 2.0.0
6+
* @copyright Tom MacWright
7+
* @license BSD
8+
*/
9+
module.exports = function () {
10+
// this returns 1
11+
return 1;
12+
};

test/fixture/meta.output.json

+247
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
[
2+
{
3+
"description": {
4+
"type": "root",
5+
"children": [
6+
{
7+
"type": "paragraph",
8+
"children": [
9+
{
10+
"type": "text",
11+
"value": "This function returns the number one.",
12+
"position": {
13+
"start": {
14+
"line": 1,
15+
"column": 1,
16+
"offset": 0
17+
},
18+
"end": {
19+
"line": 1,
20+
"column": 38,
21+
"offset": 37
22+
},
23+
"indent": []
24+
}
25+
}
26+
],
27+
"position": {
28+
"start": {
29+
"line": 1,
30+
"column": 1,
31+
"offset": 0
32+
},
33+
"end": {
34+
"line": 1,
35+
"column": 38,
36+
"offset": 37
37+
},
38+
"indent": []
39+
}
40+
}
41+
],
42+
"position": {
43+
"start": {
44+
"line": 1,
45+
"column": 1,
46+
"offset": 0
47+
},
48+
"end": {
49+
"line": 1,
50+
"column": 38,
51+
"offset": 37
52+
}
53+
}
54+
},
55+
"tags": [
56+
{
57+
"title": "returns",
58+
"description": "numberone",
59+
"lineNumber": 2,
60+
"type": {
61+
"type": "NameExpression",
62+
"name": "number"
63+
}
64+
},
65+
{
66+
"title": "version",
67+
"description": "1.0.0",
68+
"lineNumber": 3
69+
},
70+
{
71+
"title": "since",
72+
"description": "2.0.0",
73+
"lineNumber": 4
74+
},
75+
{
76+
"title": "copyright",
77+
"description": "Tom MacWright",
78+
"lineNumber": 5
79+
},
80+
{
81+
"title": "license",
82+
"description": "BSD",
83+
"lineNumber": 6
84+
}
85+
],
86+
"loc": {
87+
"start": {
88+
"line": 1,
89+
"column": 0
90+
},
91+
"end": {
92+
"line": 8,
93+
"column": 3
94+
}
95+
},
96+
"context": {
97+
"loc": {
98+
"start": {
99+
"line": 9,
100+
"column": 0
101+
},
102+
"end": {
103+
"line": 12,
104+
"column": 2
105+
}
106+
}
107+
},
108+
"augments": [],
109+
"errors": [],
110+
"examples": [],
111+
"params": [],
112+
"properties": [],
113+
"returns": [
114+
{
115+
"description": {
116+
"type": "root",
117+
"children": [
118+
{
119+
"type": "paragraph",
120+
"children": [
121+
{
122+
"type": "text",
123+
"value": "numberone",
124+
"position": {
125+
"start": {
126+
"line": 1,
127+
"column": 1,
128+
"offset": 0
129+
},
130+
"end": {
131+
"line": 1,
132+
"column": 10,
133+
"offset": 9
134+
},
135+
"indent": []
136+
}
137+
}
138+
],
139+
"position": {
140+
"start": {
141+
"line": 1,
142+
"column": 1,
143+
"offset": 0
144+
},
145+
"end": {
146+
"line": 1,
147+
"column": 10,
148+
"offset": 9
149+
},
150+
"indent": []
151+
}
152+
}
153+
],
154+
"position": {
155+
"start": {
156+
"line": 1,
157+
"column": 1,
158+
"offset": 0
159+
},
160+
"end": {
161+
"line": 1,
162+
"column": 10,
163+
"offset": 9
164+
}
165+
}
166+
},
167+
"title": "returns",
168+
"type": {
169+
"type": "NameExpression",
170+
"name": "number"
171+
}
172+
}
173+
],
174+
"sees": [],
175+
"throws": [],
176+
"todos": [],
177+
"version": "1.0.0",
178+
"since": "2.0.0",
179+
"copyright": {
180+
"type": "root",
181+
"children": [
182+
{
183+
"type": "paragraph",
184+
"children": [
185+
{
186+
"type": "text",
187+
"value": "Tom MacWright",
188+
"position": {
189+
"start": {
190+
"line": 1,
191+
"column": 1,
192+
"offset": 0
193+
},
194+
"end": {
195+
"line": 1,
196+
"column": 14,
197+
"offset": 13
198+
},
199+
"indent": []
200+
}
201+
}
202+
],
203+
"position": {
204+
"start": {
205+
"line": 1,
206+
"column": 1,
207+
"offset": 0
208+
},
209+
"end": {
210+
"line": 1,
211+
"column": 14,
212+
"offset": 13
213+
},
214+
"indent": []
215+
}
216+
}
217+
],
218+
"position": {
219+
"start": {
220+
"line": 1,
221+
"column": 1,
222+
"offset": 0
223+
},
224+
"end": {
225+
"line": 1,
226+
"column": 14,
227+
"offset": 13
228+
}
229+
}
230+
},
231+
"license": "BSD",
232+
"name": "meta.input",
233+
"kind": "function",
234+
"members": {
235+
"instance": [],
236+
"static": [],
237+
"events": []
238+
},
239+
"path": [
240+
{
241+
"name": "meta.input",
242+
"kind": "function"
243+
}
244+
],
245+
"namespace": "meta.input"
246+
}
247+
]

test/fixture/meta.output.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2+
3+
### Table of Contents
4+
5+
- [meta.input](#metainput)
6+
7+
## meta.input
8+
9+
This function returns the number one.
10+
11+
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** numberone
12+
13+
**Meta**
14+
15+
- **version**: 1.0.0
16+
- **since**: 2.0.0
17+
- **copyright**: Tom MacWright
18+
19+
- **license**: BSD

0 commit comments

Comments
 (0)