Skip to content

Commit 31993c2

Browse files
committed
Remove keyof resolution option
1 parent 9f7baa9 commit 31993c2

File tree

5 files changed

+0
-105
lines changed

5 files changed

+0
-105
lines changed

src/convert/keyof-comment-resolver.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
Comment,
3-
CommentTag,
43
DeclarationReflection,
54
ProjectReflection,
65
ReferenceType,
@@ -16,35 +15,6 @@ import join from '../util/join';
1615
import { propertySorter } from '../util/sort';
1716

1817
export default class KeyOfCommentResolver {
19-
public resolveKeys(project: ProjectReflection, reflection: Reflection, override: boolean = false) {
20-
const node = reflection as DeclarationReflection;
21-
const type = node.type as TypeOperatorType;
22-
const reference = this.getDeclaration(project, type.target);
23-
24-
let keys = this.getKeys(reference)
25-
.sort(propertySorter(r => r.id))
26-
.map(r => type.target?.type === 'reference' ? `[[${(type.target as ReferenceType)?.name}.${r.name}|\`${r.name}\`]]` : `\`${r.name}\``)
27-
.join(', ');
28-
29-
if (!node.comment) {
30-
node.comment = new Comment();
31-
}
32-
33-
if (!node.comment.tags) {
34-
node.comment.tags = [];
35-
}
36-
37-
let tag = node.comment.getTag('keys');
38-
if (tag) {
39-
if (override) {
40-
tag.text = keys;
41-
}
42-
} else {
43-
tag = new CommentTag('keys', undefined, keys);
44-
node.comment.tags.push(tag);
45-
}
46-
}
47-
4818
public shouldResolveKeys(project: ProjectReflection, reflection: Reflection) {
4919
const node = reflection as DeclarationReflection;
5020

src/keyof-plugin.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,11 @@
11
import { Context, Converter } from 'typedoc/dist/lib/converter';
2-
import { DeclarationOption, ParameterType } from 'typedoc/dist/lib/utils/options/declaration';
3-
import { BindOption } from 'typedoc/dist/lib/utils';
42
import { ConverterComponent } from 'typedoc/dist/lib/converter/components';
53
import KeyOfCommentResolver from './convert/keyof-comment-resolver';
64

7-
export enum AddKeysTagOption {
8-
off = 0,
9-
add = 1,
10-
update = 2,
11-
}
12-
13-
export const addKeysOptionMapping: { [key: string]: AddKeysTagOption } = {
14-
off: AddKeysTagOption.off,
15-
add: AddKeysTagOption.add,
16-
update: AddKeysTagOption.update,
17-
};
18-
19-
const keyofCommentsOption = {
20-
name: 'keyofComments',
21-
type: ParameterType.Map,
22-
help: 'Expands the values of the keyof operator and adds a tag, default is set to off',
23-
defaultValue: AddKeysTagOption.off,
24-
map: addKeysOptionMapping,
25-
} as DeclarationOption;
26-
275
export class KeyOfPlugin extends ConverterComponent {
286
static options = [
29-
keyofCommentsOption,
307
];
318

32-
@BindOption(keyofCommentsOption.name)
33-
_mode!: AddKeysTagOption;
34-
359
protected initialize() {
3610
this.listenTo(this.owner, {
3711
[Converter.EVENT_RESOLVE_BEGIN]: this.onBeginResolve,
@@ -40,14 +14,6 @@ export class KeyOfPlugin extends ConverterComponent {
4014

4115
private onBeginResolve(context: Context) {
4216
const resolver = KeyOfCommentResolver.instance();
43-
if (this._mode !== AddKeysTagOption.off) {
44-
const override = this._mode === AddKeysTagOption.update;
45-
46-
Object.values(context.project.reflections)
47-
.filter(item => resolver.shouldResolveKeys(context.project, item))
48-
.forEach(item => resolver.resolveKeys(context.project, item, override));
49-
}
50-
5117
Object.values(context.project.reflections)
5218
.filter(item => resolver.shouldInlineKeys(context.project, item))
5319
.forEach(item => resolver.inlineKeys(context.project, item));

tests/dynamic-tests.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ describe('Dynamic test suite', () => {
8383
const keyOfResolver = KeyOfCommentResolver.instance();
8484

8585
const reflectionsToRemove = filter.filterReflections(Object.values(project.reflections), Version.parse('1.0'));
86-
const reflectionsWithKeys = Object.values(project.reflections).filter(r => keyOfResolver.shouldResolveKeys(project, r));
8786
const reflectionsToInline = Object.values(project.reflections).filter(r => keyOfResolver.shouldInlineKeys(project, r));
8887

8988
filter.removeReflections(project, reflectionsToRemove);
90-
reflectionsWithKeys.forEach(r => keyOfResolver.resolveKeys(project, r));
9189
reflectionsToInline.forEach(r => keyOfResolver.inlineKeys(project, r));
9290

9391
OmitTagsPlugin.removeTags(Object.values(project.reflections), ['stuff']);

tests/test-data/type/operator-expected.d.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
declare module test {
2-
/**
3-
* @keys [[StatusTypes.success|`success`]], [[StatusTypes.failure|`failure`]]
4-
*/
52
type StatusType = keyof StatusTypes;
63

74
type StatusTypes = {
@@ -33,27 +30,8 @@ declare module test {
3330
*
3431
* - switch
3532
* - television
36-
*
37-
* @keys `on`, `off`
3833
*/
3934
type DynamicType = "on" | "off";
4035

41-
/**
42-
* Should leave these keys tag alone
43-
*
44-
* @keys on | off
45-
* | ON | OFF
46-
*/
47-
type LeaveThisAlone = keyof {
48-
/**
49-
* Turns stuff on
50-
*/
51-
on: string,
52-
/**
53-
* Turns stuff off
54-
*/
55-
off: string,
56-
};
57-
5836
type Reference = "on" | "off";
5937
}

tests/test-data/type/operator-input.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,5 @@ export module test {
3535
off: string,
3636
};
3737

38-
/**
39-
* Should leave these keys tag alone
40-
*
41-
* @keys on | off
42-
* | ON | OFF
43-
*/
44-
export type LeaveThisAlone = keyof {
45-
/**
46-
* Turns stuff on
47-
*/
48-
on: string,
49-
/**
50-
* Turns stuff off
51-
*/
52-
off: string,
53-
};
54-
5538
export type Reference = "on" | "off";
5639
}

0 commit comments

Comments
 (0)