Skip to content

Commit 59ae49e

Browse files
Feature: interface plugin (#12)
1 parent 9ce8563 commit 59ae49e

13 files changed

Lines changed: 2353 additions & 250 deletions

File tree

common/config/rush/npm-shrinkwrap.json

Lines changed: 338 additions & 133 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 546 additions & 2 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ public GetFoo(arg: string | number): string
5252
```
5353
#### Parameters
5454

55-
| Name | Type |
56-
| ---- | ---------------- |
57-
| arg | string \| number |
55+
| Name | Type |
56+
| ---- | -------------------- |
57+
| arg | string | number |
5858

5959

6060
## Properties

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

Lines changed: 102 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,94 @@
11
// tslint:disable
22

3+
export interface ExtendedBar extends Foo<number>, Boo {
4+
OtherStuff: string[];
5+
}
6+
7+
export interface Foo<TType> {
8+
Name: string;
9+
Surname: string;
10+
Type: TType;
11+
}
12+
13+
export interface Boo {
14+
Boos: string[];
15+
}
16+
17+
export interface AnotherInterface {
18+
<TValue>(param1: TValue, param2: TValue): boolean;
19+
}
20+
21+
export interface MyConstraintType {
22+
myProperty: string;
23+
}
24+
25+
export interface MyDefaultType extends MyConstraintType {
26+
anotherProperty: number;
27+
}
28+
29+
export interface ObjectsInterface {
30+
objectOne: Object;
31+
objectTwo: Object;
32+
}
33+
34+
export interface InterfaceWithCall {
35+
<T>(): { someProperty: T };
36+
}
37+
38+
export interface InterfaceWithConstraintType extends Dictionary<string> {
39+
someProperty: string;
40+
}
41+
42+
export interface InterfaceWithMethod<T> {
43+
someMethodOne(): T;
44+
someMethodTwo<TReturn>(): TReturn;
45+
}
46+
47+
export interface Dictionary<TValue> {
48+
new(): Dictionary<TValue>;
49+
[key: string]: TValue;
50+
}
51+
52+
export interface MethodsInterface {
53+
someMethod<T>(): string;
54+
<TValue>(arg: TValue): void;
55+
}
56+
57+
/**
58+
* Monster interface
59+
* @beta
60+
* @deprecated
61+
*/
62+
export interface MonsterInterface<TValue extends Object = {}> extends ObjectsInterface {
63+
new <T>(): MonsterInterface<T>;
64+
new(someParameter: string): string;
65+
66+
readonly [key: string]: TValue;
67+
68+
<T>(): { someProperty: T };
69+
<T>(key?: string): { someProperty: T };
70+
<T>(key: number): { someProperty: T };
71+
72+
readonly objectOne: TValue;
73+
objectTwo: TValue;
74+
}
75+
76+
export interface SomeInterface {
77+
[key: string]: string | number;
78+
[key: number]: string;
79+
}
80+
81+
export interface StringsDictionary {
82+
[key: string]: string;
83+
}
84+
85+
export interface MyInterface {
86+
MyPropertyOne: string;
87+
MyPropertyTwo: Object;
88+
MyPropertyThree: number;
89+
}
90+
91+
392
// import { Foo } from "./exported-functions";
493

594
// export class World { }
@@ -211,18 +300,18 @@
211300
// }
212301
// }
213302

214-
export class Hello {
215-
/**
216-
* This is a constructor
217-
* @param arg This is an argument ;)
218-
*/
219-
constructor(arg: string) { }
303+
// export class Hello {
304+
// /**
305+
// * This is a constructor
306+
// * @param arg This is an argument ;)
307+
// */
308+
// constructor(arg: string) { }
220309

221-
GetFoo(arg: number): string
222-
GetFoo(arg: string): string
223-
GetFoo(arg: string | number): string {
224-
throw new Error("Method not implemented.");
225-
}
310+
// GetFoo(arg: number): string
311+
// GetFoo(arg: string): string
312+
// GetFoo(arg: string | number): string {
313+
// throw new Error("Method not implemented.");
314+
// }
226315

227-
public Foo: string;
228-
}
316+
// public Foo: string;
317+
// }

packages/ts-docs-gen/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"engine": "node >= 7.5.0",
1616
"author": "simplrjs <simplr@quatrodev.com> (https://github.com/simplrjs)",
1717
"dependencies": {
18-
"@simplrjs/markdown": "^1.0.3",
18+
"@simplrjs/markdown": "^1.0.7",
1919
"@types/fs-extra": "^5.0.0",
2020
"fast-glob": "^1.0.1",
2121
"fs-extra": "^5.0.0",
2222
"simplr-logger": "^1.0.1",
23-
"ts-extractor": "^3.0.1",
23+
"ts-extractor": "^3.0.3",
2424
"typescript": "^2.6.2"
2525
},
2626
"devDependencies": {

packages/ts-docs-gen/src/default-plugins.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { ApiEnumPlugin } from "./plugins/api-enum-plugin";
44
import { ApiFunctionPlugin } from "./plugins/api-function-plugin";
55
import { ApiTypePlugin } from "./plugins/api-type-plugin";
66
import { ApiNamespacePlugin } from "./plugins/api-namespace-plugin";
7+
import { ApiInterfacePlugin } from "./plugins/api-interface-plugin";
8+
import { ApiCallablePlugin } from "./plugins/api-callable-plugin";
9+
import { ApiIndexPlugin } from "./plugins/api-index-plugin";
710
import { ApiClassPlugin } from "./plugins/api-class-plugin";
811
import { ApiClassConstructorPlugin } from "./plugins/api-class-constructor-plugin";
912
import { ApiClassMethodPlugin } from "./plugins/api-class-method-plugin";
@@ -16,6 +19,9 @@ export const DefaultPlugins = [
1619
new ApiFunctionPlugin(),
1720
new ApiTypePlugin(),
1821
new ApiNamespacePlugin(),
22+
new ApiInterfacePlugin(),
23+
new ApiCallablePlugin(),
24+
new ApiIndexPlugin(),
1925
new ApiClassPlugin(),
2026
new ApiClassConstructorPlugin(),
2127
new ApiClassMethodPlugin(),

0 commit comments

Comments
 (0)