Skip to content

Commit b682f23

Browse files
Feature: interface improvements (#15)
1 parent c9bb9ff commit b682f23

6 files changed

Lines changed: 83 additions & 166 deletions

File tree

packages/ts-docs-gen/examples/simple/docs/api/index.md

Lines changed: 34 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
[InterfaceDeclaration-1]: index.md#foo
2-
[InterfaceDeclaration-2]: index.md#boo
3-
[InterfaceDeclaration-4]: index.md#myconstrainttype
4-
[InterfaceDeclaration-9]: index.md#dictionary
5-
[InterfaceDeclaration-9]: index.md#dictionary
6-
[InterfaceDeclaration-6]: index.md#objectsinterface
7-
[InterfaceDeclaration-12]: index.md#monsterinterface
1+
[InterfaceDeclaration-1]: index.md#interface-foo
2+
[InterfaceDeclaration-2]: index.md#interface-boo
3+
[InterfaceDeclaration-4]: index.md#interface-myconstrainttype
4+
[InterfaceDeclaration-9]: index.md#interface-dictionary
5+
[InterfaceDeclaration-9]: index.md#interface-dictionary
6+
[InterfaceDeclaration-6]: index.md#interface-objectsinterface
7+
[InterfaceDeclaration-12]: index.md#interface-monsterinterface
88
[ClassDeclaration-0]: index/hello.md#hello
99
# index
1010

@@ -80,26 +80,23 @@ interface AnotherInterface {
8080
<TValue>(param1: TValue, param2: TValue): boolean
8181
```
8282
83-
Type parameters:
83+
**Type parameters:**
8484
8585
| Name |
8686
| ------ |
8787
| TValue |
8888
89-
Parameters:
89+
**Parameters:**
9090
9191
| Name | Type |
9292
| ------ | ------ |
9393
| param1 | TValue |
9494
| param2 | TValue |
9595
96-
Return type:
96+
**Return type:**
9797
9898
true | false
9999
100-
---
101-
102-
103100
## interface MyConstraintType
104101
105102
```typescript
@@ -162,19 +159,16 @@ interface InterfaceWithCall {
162159
<T>(): { someProperty: T; }
163160
```
164161
165-
Type parameters:
162+
**Type parameters:**
166163
167164
| Name |
168165
| ---- |
169166
| T |
170167
171-
Return type:
168+
**Return type:**
172169
173170
{ someProperty: T; }
174171
175-
---
176-
177-
178172
## interface InterfaceWithConstraintType
179173
180174
```typescript
@@ -214,29 +208,24 @@ interface InterfaceWithMethod<T> {
214208
someMethodOne(): T
215209
```
216210

217-
Return type:
211+
**Return type:**
218212

219213
T
220214

221-
---
222-
223215
```typescript
224216
someMethodTwo<TReturn>(): TReturn
225217
```
226218

227-
Type parameters:
219+
**Type parameters:**
228220

229221
| Name |
230222
| ------- |
231223
| TReturn |
232224

233-
Return type:
225+
**Return type:**
234226

235227
TReturn
236228

237-
---
238-
239-
240229
## interface Dictionary
241230

242231
```typescript
@@ -258,12 +247,10 @@ interface Dictionary<TValue> {
258247
new (): Dictionary<TValue>
259248
```
260249
261-
Return type:
250+
**Return type:**
262251
263252
[Dictionary][InterfaceDeclaration-9]&#60;TValue&#62;
264253
265-
---
266-
267254
### Index signatures
268255
269256
```typescript
@@ -274,9 +261,6 @@ Index `key` - string
274261
275262
Type - TValue
276263
277-
---
278-
279-
280264
## interface MethodsInterface
281265
282266
```typescript
@@ -292,43 +276,38 @@ interface MethodsInterface {
292276
<TValue>(arg: TValue): void
293277
```
294278
295-
Type parameters:
279+
**Type parameters:**
296280
297281
| Name |
298282
| ------ |
299283
| TValue |
300284
301-
Parameters:
285+
**Parameters:**
302286
303287
| Name | Type |
304288
| ---- | ------ |
305289
| arg | TValue |
306290
307-
Return type:
291+
**Return type:**
308292
309293
void
310294
311-
---
312-
313295
### Methods
314296
315297
```typescript
316298
someMethod<T>(): string
317299
```
318300
319-
Type parameters:
301+
**Type parameters:**
320302
321303
| Name |
322304
| ---- |
323305
| T |
324306
325-
Return type:
307+
**Return type:**
326308
327309
string
328310
329-
---
330-
331-
332311
## interface MonsterInterface
333312
334313
<span style="color: #d2d255;">Warning: Beta!</span>
@@ -345,7 +324,7 @@ interface MonsterInterface<TValue extends Object = {}> extends ObjectsInterface
345324
<T>(key?: string | undefined): { someProperty: T; };
346325
<T>(key: number): { someProperty: T; };
347326
readonly [key: string]: TValue;
348-
readonly objectOne?: TValue;
327+
readonly objectOne: TValue;
349328
objectTwo: TValue;
350329
}
351330
```
@@ -366,96 +345,86 @@ interface MonsterInterface<TValue extends Object = {}> extends ObjectsInterface
366345
new <T>(): MonsterInterface<T>
367346
```
368347
369-
Type parameters:
348+
**Type parameters:**
370349
371350
| Name |
372351
| ---- |
373352
| T |
374353
375-
Return type:
354+
**Return type:**
376355
377356
[MonsterInterface][InterfaceDeclaration-12]&#60;T&#62;
378357
379-
---
380-
381358
```typescript
382359
new (someParameter: string): string
383360
```
384361
385-
Parameters:
362+
**Parameters:**
386363
387364
| Name | Type |
388365
| ------------- | ------ |
389366
| someParameter | string |
390367
391-
Return type:
368+
**Return type:**
392369
393370
string
394371
395-
---
396-
397372
### Call
398373
399374
```typescript
400375
<T>(): { someProperty: T; }
401376
```
402377
403-
Type parameters:
378+
**Type parameters:**
404379
405380
| Name |
406381
| ---- |
407382
| T |
408383
409-
Return type:
384+
**Return type:**
410385
411386
{ someProperty: T; }
412387
413-
---
414-
415388
```typescript
416389
<T>(key?: string | undefined): { someProperty: T; }
417390
```
418391
419-
Type parameters:
392+
**Type parameters:**
420393
421394
| Name |
422395
| ---- |
423396
| T |
424397
425-
Parameters:
398+
**Parameters:**
426399
427400
| Name | Type | Optional |
428401
| ---- | ----------------------- | -------- |
429402
| key | undefined &#124; string | Yes |
430403
431-
Return type:
404+
**Return type:**
432405
433406
{ someProperty: T; }
434407
435-
---
436-
437408
```typescript
438409
<T>(key: number): { someProperty: T; }
439410
```
440411
441-
Type parameters:
412+
**Type parameters:**
442413
443414
| Name |
444415
| ---- |
445416
| T |
446417
447-
Parameters:
418+
**Parameters:**
448419
449420
| Name | Type |
450421
| ---- | ------ |
451422
| key | number |
452423
453-
Return type:
424+
**Return type:**
454425
455426
{ someProperty: T; }
456427
457-
---
458-
459428
### Index signatures
460429
461430
```typescript
@@ -468,8 +437,6 @@ Index `key` - string
468437
469438
Type - TValue
470439
471-
---
472-
473440
### Properties
474441
475442
| Name | Type |
@@ -496,8 +463,6 @@ Index `key` - string
496463

497464
Type - string | number
498465

499-
---
500-
501466
```typescript
502467
[key: number]: string
503468
```
@@ -506,9 +471,6 @@ Index `key` - number
506471

507472
Type - string
508473

509-
---
510-
511-
512474
## interface StringsDictionary
513475

514476
```typescript
@@ -527,9 +489,6 @@ Index `key` - string
527489

528490
Type - string
529491

530-
---
531-
532-
533492
## interface MyInterface
534493

535494
```typescript

packages/ts-docs-gen/src/file-manager.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface OutputData {
1414

1515
type RenderedItemList = Array<PluginResult | OutputData>;
1616

17+
// TODO: remove unused files before generating docs.
1718
export class FileManager {
1819
/**
1920
* <FileLocation, RenderedItems>

packages/ts-docs-gen/src/plugins/api-callable-plugin.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export class ApiCallablePlugin implements Plugin<CallableApiItem> {
2424
parameters: Contracts.ApiParameterDto[],
2525
typeParameters: Contracts.ApiTypeParameterDto[]
2626
): string {
27-
2827
switch (apiItem.ApiKind) {
2928
case Contracts.ApiItemKinds.Construct: {
3029
return GeneratorHelpers.ApiConstructToString(typeParameters, parameters, apiItem.ReturnType);
@@ -58,7 +57,7 @@ export class ApiCallablePlugin implements Plugin<CallableApiItem> {
5857
usedReferences.push(...table.References);
5958

6059
builder
61-
.Text("Type parameters:")
60+
.Bold("Type parameters:")
6261
.EmptyLine()
6362
.Text(table.Text)
6463
.EmptyLine();
@@ -69,7 +68,7 @@ export class ApiCallablePlugin implements Plugin<CallableApiItem> {
6968
usedReferences.push(...table.References);
7069

7170
builder
72-
.Text("Parameters:")
71+
.Bold("Parameters:")
7372
.EmptyLine()
7473
.Text(table.Text)
7574
.EmptyLine();
@@ -79,7 +78,7 @@ export class ApiCallablePlugin implements Plugin<CallableApiItem> {
7978
const renderedReturnType = GeneratorHelpers.TypeDtoToMarkdownString(data.ApiItem.ReturnType);
8079

8180
builder
82-
.Text("Return type:")
81+
.Bold("Return type:")
8382
.EmptyLine()
8483
.Text(renderedReturnType.Text);
8584

0 commit comments

Comments
 (0)