Skip to content

Commit 2463a88

Browse files
author
Martynas Žilinskas
authored
Feature: Cli (#31)
1 parent 2ef376a commit 2463a88

23 files changed

+410
-76
lines changed

common/config/rush/npm-shrinkwrap.json

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

packages/ts-docs-gen/docs-gen.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entryFile": "./src/index.ts"
3+
}

packages/ts-docs-gen/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
"dependencies": {
1818
"@simplrjs/markdown": "^1.1.0",
1919
"@types/fs-extra": "^5.0.0",
20+
"@types/yargs": "^10.0.1",
2021
"fs-extra": "^5.0.0",
2122
"simplr-logger": "^1.0.1",
2223
"ts-extractor": "^4.0.0-beta.8",
23-
"typescript": "^2.6.2"
24+
"typescript": "^2.6.2",
25+
"yargs": "^11.0.0"
2426
},
2527
"devDependencies": {
2628
"@simplrjs/test-generator-cli": "^0.1.3",
@@ -32,6 +34,7 @@
3234
"ts-jest": "^22.0.1",
3335
"tslint": "^5.9.1"
3436
},
37+
"bin": "./dist/cli/launcher.js",
3538
"jest": {
3639
"collectCoverage": true,
3740
"mapCoverage": true,

packages/ts-docs-gen/src/abstractions/base-plugin.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ import { ApiTypes } from "../api-items/api-type-list";
88
import { ReferenceRenderHandler } from "../contracts/serialized-api-item";
99

1010
export abstract class BasePlugin<TKind extends Contracts.ApiBaseDefinition = Contracts.ApiDefinition> implements Plugin<TKind> {
11+
/**
12+
* Used to identify class as Plugin.
13+
*/
14+
// tslint:disable-next-line:no-empty
15+
public static TsDocsGenPlugin(): void { }
16+
1117
public abstract SupportedApiDefinitionKind(): SupportedApiItemKindType[];
1218

1319
public CheckApiItem(item: TKind): boolean {

packages/ts-docs-gen/src/abstractions/container-plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export abstract class ContainerPlugin<TKind extends ApiContainer> extends BasePl
8282
} else {
8383
switch (member.ApiItem.ApiKind) {
8484
case Contracts.ApiDefinitionKind.Namespace:
85+
case Contracts.ApiDefinitionKind.ImportNamespace:
8586
case Contracts.ApiDefinitionKind.Class: {
8687
const renderedItem = pluginOptions.GetItemPluginResult(member.Reference);
8788
pluginResultData.Members.push({

packages/ts-docs-gen/src/api-items/api-callable.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,13 @@ export abstract class ApiCallable<TKind extends Contracts.ApiCallableBaseDefinit
6767
const parametersString = this.ParametersToString(render);
6868

6969
// ReturnType
70-
const type = this.SerializedTypeToString(render, this.ReturnType);
71-
const returnTypeString = typeDefChar !== "" && type != null ? `${typeDefChar}${type}` : "";
70+
let returnTypeString: string;
71+
if (typeDefChar !== "" && this.ReturnType != null) {
72+
const type = this.SerializedTypeToString(render, this.ReturnType);
73+
returnTypeString = `${typeDefChar}${type}`;
74+
} else {
75+
returnTypeString = "";
76+
}
7277

7378
return `${typeParametersString}(${parametersString})${returnTypeString}`;
7479
}

packages/ts-docs-gen/src/api-items/api-definition-default.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { BaseApiItemClass } from "../abstractions/base-api-item";
44
import { ApiItemReference } from "../contracts/api-item-reference";
55
import { GeneratorHelpers } from "../generator-helpers";
66

7-
// Because of circular dependency we had to
8-
// implement interface and not extend ApiDefinitionBase.
7+
// Because of circular dependency we had to implement interface and not extend ApiDefinitionBase.
98
export class ApiDefinitionDefault<TKind extends Contracts.ApiBaseDefinition = Contracts.ApiBaseDefinition>
109
extends BaseApiItemClass<TKind> implements SerializedApiDefinition<TKind> {
1110

@@ -37,10 +36,6 @@ export class ApiDefinitionDefault<TKind extends Contracts.ApiBaseDefinition = Co
3736
return this.ApiItem.Name;
3837
}
3938

40-
public get ApiItem(): TKind {
41-
return this.ApiItem;
42-
}
43-
4439
public ToText(render: ReferenceRenderHandler = this.DefaultReferenceRenderer): string[] {
4540
return [this.Name];
4641
}

packages/ts-docs-gen/src/api-items/api-definition-list.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,32 @@ import { ApiClassProperty } from "./definitions/api-class-property";
2727
import { ApiClassMethod } from "./definitions/api-class-method";
2828
import { ApiAccessor } from "./definitions/api-accessor";
2929

30+
export {
31+
ApiSourceFile,
32+
ApiCall,
33+
ApiClass,
34+
ApiConstruct,
35+
ApiEnum,
36+
ApiEnumMember,
37+
ApiFunction,
38+
ApiFunctionExpression,
39+
ApiIndex,
40+
ApiInterface,
41+
ApiMapped,
42+
ApiMethod,
43+
ApiNamespace,
44+
ApiParameter,
45+
ApiProperty,
46+
ApiTypeAlias,
47+
ApiTypeParameter,
48+
ApiVariable,
49+
ApiTypeLiteral,
50+
ApiClassConstructor,
51+
ApiClassProperty,
52+
ApiClassMethod,
53+
ApiAccessor
54+
};
55+
3056
export type ApiDefinitions = ApiDefinitionDefault |
3157
ApiSourceFile |
3258
ApiEnum |

packages/ts-docs-gen/src/api-items/api-type-list.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,20 @@ import { ApiIndexedAccess } from "./types/api-type-indexed-access";
1515
import { ApiTypeParenthesized } from "./types/api-type-parenthesized";
1616
import { ApiTypeQuery } from "./types/api-type-query";
1717

18+
export {
19+
ApiTypeBasic,
20+
ApiTypeReference,
21+
ApiTypeUnionOrIntersection,
22+
ApiTypeArray,
23+
ApiTypeTuple,
24+
ApiTypeDefinition,
25+
ApiTypePredicate,
26+
ApiTypeOperator,
27+
ApiIndexedAccess,
28+
ApiTypeParenthesized,
29+
ApiTypeQuery
30+
};
31+
1832
export type ApiTypes = ApiTypeDefault |
1933
ApiTypeBasic |
2034
ApiTypeReference |

0 commit comments

Comments
 (0)