File tree 3 files changed +312
-0
lines changed
3 files changed +312
-0
lines changed Original file line number Diff line number Diff line change 1
1
// Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
3
+ exports[`Use Source attribute only 1`] = `
4
+ Array [
5
+ Object {
6
+ "augments": Array [],
7
+ "context": Object {
8
+ "loc": SourceLocation {
9
+ "end": Position {
10
+ "column": 1,
11
+ "line": 18,
12
+ },
13
+ "start": Position {
14
+ "column": 0,
15
+ "line": 6,
16
+ },
17
+ },
18
+ },
19
+ "description": Object {
20
+ "children": Array [
21
+ Object {
22
+ "children": Array [
23
+ Object {
24
+ "position": Position {
25
+ "end": Object {
26
+ "column": 29,
27
+ "line": 1,
28
+ "offset": 28,
29
+ },
30
+ "indent": Array [],
31
+ "start": Object {
32
+ "column": 1,
33
+ "line": 1,
34
+ "offset": 0,
35
+ },
36
+ },
37
+ "type": "text",
38
+ "value": "This Vue Component is a test",
39
+ },
40
+ ],
41
+ "position": Position {
42
+ "end": Object {
43
+ "column": 29,
44
+ "line": 1,
45
+ "offset": 28,
46
+ },
47
+ "indent": Array [],
48
+ "start": Object {
49
+ "column": 1,
50
+ "line": 1,
51
+ "offset": 0,
52
+ },
53
+ },
54
+ "type": "paragraph",
55
+ },
56
+ ],
57
+ "position": Object {
58
+ "end": Object {
59
+ "column": 29,
60
+ "line": 1,
61
+ "offset": 28,
62
+ },
63
+ "start": Object {
64
+ "column": 1,
65
+ "line": 1,
66
+ "offset": 0,
67
+ },
68
+ },
69
+ "type": "root",
70
+ },
71
+ "errors": Array [
72
+ Object {
73
+ "message": "could not determine @name for hierarchy",
74
+ },
75
+ ],
76
+ "examples": Array [],
77
+ "loc": SourceLocation {
78
+ "end": Position {
79
+ "column": 3,
80
+ "line": 5,
81
+ },
82
+ "start": Position {
83
+ "column": 0,
84
+ "line": 2,
85
+ },
86
+ },
87
+ "members": Object {
88
+ "events": Array [],
89
+ "global": Array [],
90
+ "inner": Array [],
91
+ "instance": Array [],
92
+ "static": Array [],
93
+ },
94
+ "name": "",
95
+ "namespace": "",
96
+ "params": Array [],
97
+ "path": Array [
98
+ Object {
99
+ "kind": undefined,
100
+ "name": "",
101
+ },
102
+ ],
103
+ "properties": Array [],
104
+ "returns": Array [
105
+ Object {
106
+ "description": Object {
107
+ "children": Array [
108
+ Object {
109
+ "children": Array [
110
+ Object {
111
+ "position": Position {
112
+ "end": Object {
113
+ "column": 21,
114
+ "line": 1,
115
+ "offset": 20,
116
+ },
117
+ "indent": Array [],
118
+ "start": Object {
119
+ "column": 1,
120
+ "line": 1,
121
+ "offset": 0,
122
+ },
123
+ },
124
+ "type": "text",
125
+ "value": "vue-tested component",
126
+ },
127
+ ],
128
+ "position": Position {
129
+ "end": Object {
130
+ "column": 21,
131
+ "line": 1,
132
+ "offset": 20,
133
+ },
134
+ "indent": Array [],
135
+ "start": Object {
136
+ "column": 1,
137
+ "line": 1,
138
+ "offset": 0,
139
+ },
140
+ },
141
+ "type": "paragraph",
142
+ },
143
+ ],
144
+ "position": Object {
145
+ "end": Object {
146
+ "column": 21,
147
+ "line": 1,
148
+ "offset": 20,
149
+ },
150
+ "start": Object {
151
+ "column": 1,
152
+ "line": 1,
153
+ "offset": 0,
154
+ },
155
+ },
156
+ "type": "root",
157
+ },
158
+ "title": "returns",
159
+ "type": Object {
160
+ "name": "vue-tested",
161
+ "type": "NameExpression",
162
+ },
163
+ },
164
+ ],
165
+ "sees": Array [],
166
+ "tags": Array [
167
+ Object {
168
+ "description": "vue-tested component",
169
+ "lineNumber": 2,
170
+ "title": "returns",
171
+ "type": Object {
172
+ "name": "vue-tested",
173
+ "type": "NameExpression",
174
+ },
175
+ },
176
+ ],
177
+ "throws": Array [],
178
+ "todos": Array [],
179
+ },
180
+ Object {
181
+ "augments": Array [],
182
+ "context": Object {
183
+ "loc": SourceLocation {
184
+ "end": Position {
185
+ "column": 5,
186
+ "line": 16,
187
+ },
188
+ "start": Position {
189
+ "column": 4,
190
+ "line": 13,
191
+ },
192
+ },
193
+ },
194
+ "description": Object {
195
+ "children": Array [
196
+ Object {
197
+ "children": Array [
198
+ Object {
199
+ "position": Position {
200
+ "end": Object {
201
+ "column": 17,
202
+ "line": 1,
203
+ "offset": 16,
204
+ },
205
+ "indent": Array [],
206
+ "start": Object {
207
+ "column": 1,
208
+ "line": 1,
209
+ "offset": 0,
210
+ },
211
+ },
212
+ "type": "text",
213
+ "value": "This is a number",
214
+ },
215
+ ],
216
+ "position": Position {
217
+ "end": Object {
218
+ "column": 17,
219
+ "line": 1,
220
+ "offset": 16,
221
+ },
222
+ "indent": Array [],
223
+ "start": Object {
224
+ "column": 1,
225
+ "line": 1,
226
+ "offset": 0,
227
+ },
228
+ },
229
+ "type": "paragraph",
230
+ },
231
+ ],
232
+ "position": Object {
233
+ "end": Object {
234
+ "column": 17,
235
+ "line": 1,
236
+ "offset": 16,
237
+ },
238
+ "start": Object {
239
+ "column": 1,
240
+ "line": 1,
241
+ "offset": 0,
242
+ },
243
+ },
244
+ "type": "root",
245
+ },
246
+ "errors": Array [],
247
+ "examples": Array [],
248
+ "loc": SourceLocation {
249
+ "end": Position {
250
+ "column": 7,
251
+ "line": 12,
252
+ },
253
+ "start": Position {
254
+ "column": 4,
255
+ "line": 10,
256
+ },
257
+ },
258
+ "members": Object {
259
+ "events": Array [],
260
+ "global": Array [],
261
+ "inner": Array [],
262
+ "instance": Array [],
263
+ "static": Array [],
264
+ },
265
+ "name": "myNumber",
266
+ "namespace": "myNumber",
267
+ "params": Array [],
268
+ "path": Array [
269
+ Object {
270
+ "kind": undefined,
271
+ "name": "myNumber",
272
+ },
273
+ ],
274
+ "properties": Array [],
275
+ "returns": Array [],
276
+ "sees": Array [],
277
+ "tags": Array [],
278
+ "throws": Array [],
279
+ "todos": Array [],
280
+ },
281
+ ]
282
+ `;
283
+
3
284
exports[`Vue file 1`] = `
4
285
Array [
5
286
Object {
Original file line number Diff line number Diff line change @@ -241,3 +241,30 @@ test('Vue file', async function() {
241
241
normalize ( data ) ;
242
242
expect ( data ) . toMatchSnapshot ( ) ;
243
243
} ) ;
244
+
245
+ test ( 'Use Source attribute only' , async function ( ) {
246
+ await pify ( chdir ) ( __dirname ) ;
247
+ const documentationSource = `
248
+ /**
249
+ * This Vue Component is a test
250
+ * @returns {vue-tested} vue-tested component
251
+ */
252
+ export default {
253
+
254
+ props: {
255
+
256
+ /**
257
+ * This is a number
258
+ */
259
+ myNumber: {
260
+ default: 42,
261
+ type: Number
262
+ }
263
+ }
264
+ }` ;
265
+ const data = await documentation . build ( [ { source : documentationSource } ] , {
266
+ shallow : true
267
+ } ) ;
268
+ normalize ( data ) ;
269
+ expect ( data ) . toMatchSnapshot ( ) ;
270
+ } ) ;
Original file line number Diff line number Diff line change @@ -105,6 +105,10 @@ function buildInternal(inputsAndConfig) {
105
105
sourceFile . source = fs . readFileSync ( sourceFile . file , 'utf8' ) ;
106
106
}
107
107
108
+ if ( ! sourceFile . file ) {
109
+ sourceFile . file = '' ;
110
+ }
111
+
108
112
if ( path . extname ( sourceFile . file ) === '.vue' ) {
109
113
return parseVueScript ( sourceFile , config ) . map ( buildPipeline ) ;
110
114
}
You can’t perform that action at this time.
0 commit comments