Skip to content

Commit f846af3

Browse files
author
RaynorChen
committed
Fix the following bug:
Extract Constructor Comment -> done. Extract Static Field Comment -> done Render Constructor comment -> not checked. Render Static Field Comment -> Not Checked.
1 parent cff4569 commit f846af3

File tree

9 files changed

+147
-80
lines changed

9 files changed

+147
-80
lines changed

components/convert-component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Parser } from '../utils/parser';
99
import { Constants } from '../utils/constants';
1010
import { InterfaceFactory } from '../utils/factories/interface-factory';
1111
import { FunctionFactory } from '../utils/factories/function-factory';
12+
import { VariableFactory } from '../utils/factories/variable-factory';
1213

1314
@Component({ name: 'convert-component' })
1415
export class ConvertComponent extends ConverterComponent {
@@ -146,6 +147,7 @@ export class ConvertComponent extends ConverterComponent {
146147
case ReflectionKind.Property:
147148
case ReflectionKind.CallSignature:
148149
case ReflectionKind.EnumMember:
150+
case ReflectionKind.Constructor:
149151
/**
150152
* Skip reflections with type @ReflectionKind.Function because they are aslo @ReflectionKInd.CallSignature
151153
* but the handling process here is not appropriate for them.
@@ -154,8 +156,10 @@ export class ConvertComponent extends ConverterComponent {
154156
break;
155157
}
156158

159+
160+
157161
const getData = this.getCommentInfo(reflection);
158-
this.factoryInstance.appendAttribute(this.jsonObjectName, reflection.kind, reflection.name, getData);
162+
this.factoryInstance.appendAttribute(this.jsonObjectName, reflection.kind, reflection.name, getData, reflection.flags.isStatic);
159163
break;
160164
case ReflectionKind.Function:
161165
const funcData = this.getCommentInfo(reflection.signatures[0]);
@@ -165,6 +169,14 @@ export class ConvertComponent extends ConverterComponent {
165169
this.globalFuncsJson = Object.assign(funcInstance.getJsonContent(), this.globalFuncsJson);
166170
}
167171
break;
172+
case ReflectionKind.Variable:
173+
const variableData = this.getCommentInfo(reflection);
174+
const variableInstance = this.instanceBuilder(reflection.kind, reflection.name);
175+
variableInstance.buildObjectStructure(variableData);
176+
if (!variableInstance.isEmpty()){
177+
this.globalFuncsJson = Object.assign(variableInstance.getJsonContent(), this.globalFuncsJson);
178+
}
179+
break;
168180
case ReflectionKind.GetSignature:
169181
case ReflectionKind.SetSignature:
170182
const accessorName = reflection.parent.name;
@@ -280,6 +292,8 @@ export class ConvertComponent extends ConverterComponent {
280292
return new FunctionFactory(objectName);
281293
case ReflectionKind.Class:
282294
return new ClassFactory(objectName);
295+
case ReflectionKind.Variable:
296+
return new VariableFactory(objectName);
283297
default:
284298
null;
285299
}

components/render-component.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'path';
33
import { Component, RendererComponent } from 'typedoc/dist/lib/output/components';
44
import { ReflectionKind } from 'typedoc/dist/lib/models';
55
import { FileOperations } from '../utils/file-operations';
6-
import { AttributeType } from '../utils/enums/json-keys';
6+
import { getAttributeType } from '../utils/enums/json-keys';
77
import { Constants } from '../utils/constants';
88
import { RendererEvent } from 'typedoc/dist/lib/output/events';
99
import { Parser } from '../utils/parser';
@@ -77,6 +77,7 @@ export class RenderComponenet extends RendererComponent {
7777
case ReflectionKind.Property:
7878
case ReflectionKind.CallSignature:
7979
case ReflectionKind.EnumMember:
80+
case ReflectionKind.Constructor:
8081
/**
8182
* Skip reflections with type @ReflectionKind.Function because they are aslo @ReflectionKInd.CallSignature
8283
* but the handling process here is not appropriate for them.
@@ -88,7 +89,11 @@ export class RenderComponenet extends RendererComponent {
8889
const parent = this.getParentBasedOnType(reflection, reflection.kind);
8990
const parentName = parent.name;
9091
const attributeName = reflection.name;
91-
const attributeData = this.getAttributeData(parentName, AttributeType[reflection.kind], attributeName);
92+
console.log(attributeName);
93+
if (ReflectionKind.Constructor === reflection.kind)
94+
debugger;
95+
96+
const attributeData = this.getAttributeData(parentName, getAttributeType(reflection.kind), attributeName, reflection.flags.isStatic);
9297
if(attributeData) {
9398
this.updateComment(reflection, attributeData);
9499
}
@@ -101,12 +106,24 @@ export class RenderComponenet extends RendererComponent {
101106
const funcData = this.globalFuncsData[funcName];
102107
this.updateComment(reflection.signatures[0], funcData);
103108
break;
109+
case ReflectionKind.Variable:
110+
if (!this.globalFuncsData) {
111+
break;
112+
}
113+
const variableName = reflection.name;
114+
const variableData = this.globalFuncsData[variableName];
115+
this.updateComment(reflection, variableData);
116+
break;
104117
case ReflectionKind.GetSignature:
105118
case ReflectionKind.SetSignature:
106119
const accessorParent = this.getParentBasedOnType(reflection, reflection.kind);
107120
const accessor = reflection.parent;
108121
const accessorSignature = reflection.kind;
109-
const data = this.getAccessorAttributeData(accessorParent.name, AttributeType[accessor.kind], accessor.name, AttributeType[accessorSignature]);
122+
const data = this.getAccessorAttributeData(accessorParent.name,
123+
getAttributeType(accessor.kind),
124+
accessor.name,
125+
getAttributeType(accessorSignature),
126+
reflection.flags.isStatic);
110127
if (data) {
111128
this.updateComment(reflection, data);
112129
}
@@ -122,15 +139,22 @@ export class RenderComponenet extends RendererComponent {
122139
}
123140
}
124141

125-
private getAttributeData(parentName, attribute, attributeName) {
142+
private getAttributeData(parentName, attribute, attributeName, isStatic) {
126143
const data = this.getAttribute(parentName, attribute);
144+
127145
if (data) {
146+
if (isStatic){
147+
if (data[Constants.STATIC_ATTRIBUTES_CATETORY_NAME]){
148+
return data[Constants.STATIC_ATTRIBUTES_CATETORY_NAME][attributeName];
149+
}
150+
}
151+
128152
return data[attributeName];
129153
}
130154
}
131155

132-
private getAccessorAttributeData(parentName, attribute, attributeName, accessorType) {
133-
const data = this.getAttributeData(parentName, attribute, attributeName);
156+
private getAccessorAttributeData(parentName, attribute, attributeName, accessorType, isStatic) {
157+
const data = this.getAttributeData(parentName, attribute, attributeName, isStatic);
134158
if (data) {
135159
return data[accessorType];
136160
}

0 commit comments

Comments
 (0)