Skip to content

Commit 6598d04

Browse files
Better Getter/Setter support
1 parent f867e52 commit 6598d04

File tree

6 files changed

+227
-0
lines changed

6 files changed

+227
-0
lines changed

bin/typedoc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,6 +3772,9 @@ var td;
37723772
Reflection.prototype.hasComment = function () {
37733773
return (this.comment && this.comment.hasVisibleComponent());
37743774
};
3775+
Reflection.prototype.hasGetterOrSetter = function () {
3776+
return false;
3777+
};
37753778
/**
37763779
* Return a child by its name.
37773780
*
@@ -4156,6 +4159,9 @@ var td;
41564159
function DeclarationReflection() {
41574160
_super.apply(this, arguments);
41584161
}
4162+
DeclarationReflection.prototype.hasGetterOrSetter = function () {
4163+
return this.getSignature || this.setSignature;
4164+
};
41594165
DeclarationReflection.prototype.getAllSignatures = function () {
41604166
var result = [];
41614167
if (this.signatures)

examples/basic/src/classes.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,19 +207,42 @@ export class SubClassA extends BaseClass implements IPrintNameInterface
207207
}
208208

209209

210+
/**
211+
* Returns the name. See [[BaseClass.name]].
212+
*
213+
* @returns The return value.
214+
*/
210215
public get nameProperty():string {
211216
return this.name;
212217
}
213218

219+
/**
220+
* Sets the name. See [[BaseClass.name]].
221+
*
222+
* @param value The new name.
223+
* @returns The return value.
224+
*/
214225
public set nameProperty(value:string) {
215226
this.name = value;
216227
}
217228

218229

230+
/**
231+
* Returns the name. See [[BaseClass.name]].
232+
*
233+
* @returns The return value.
234+
*/
219235
public get readOnlyNameProperty():string {
220236
return this.name;
221237
}
222238

239+
240+
/**
241+
* Sets the name. See [[BaseClass.name]].
242+
*
243+
* @param value The new name.
244+
* @returns The return value.
245+
*/
223246
public set writeOnlyNameProperty(value:string) {
224247
this.name = value;
225248
}

src/td/models/Reflection.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ module td
430430
}
431431

432432

433+
hasGetterOrSetter():boolean {
434+
return false;
435+
}
436+
437+
433438
/**
434439
* @param name The name of the child to look for. Might contain a hierarchy.
435440
*/

src/td/models/reflections/DeclarationReflection.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ module td
144144
typeHierarchy:IDeclarationHierarchy;
145145

146146

147+
hasGetterOrSetter():boolean {
148+
return this.getSignature || this.setSignature;
149+
}
150+
147151

148152
getAllSignatures():SignatureReflection[] {
149153
var result = [];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class GetterSetter
2+
{
3+
private _name:string;
4+
5+
6+
get name():string { return this._name; }
7+
set name(value:string) { this._name = value; }
8+
9+
get readOnlyName():string { return this._name; }
10+
11+
set writeOnlyName(value:string) { this._name = value; }
12+
}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
{
2+
"id": 0,
3+
"name": "typedoc",
4+
"kind": 0,
5+
"flags": {},
6+
"children": [
7+
{
8+
"id": 1,
9+
"name": "\"getter-setter\"",
10+
"kind": 1,
11+
"kindString": "External module",
12+
"flags": {
13+
"isExported": true
14+
},
15+
"originalName": "%BASE%/getter-setter/getter-setter.ts",
16+
"children": [
17+
{
18+
"id": 2,
19+
"name": "GetterSetter",
20+
"kind": 128,
21+
"kindString": "Class",
22+
"flags": {},
23+
"children": [
24+
{
25+
"id": 3,
26+
"name": "_name",
27+
"kind": 1024,
28+
"kindString": "Property",
29+
"flags": {
30+
"isPrivate": true
31+
},
32+
"type": {
33+
"type": "instrinct",
34+
"name": "string"
35+
}
36+
},
37+
{
38+
"id": 4,
39+
"name": "name",
40+
"kind": 262144,
41+
"kindString": "Accessor",
42+
"flags": {},
43+
"getSignature": [
44+
{
45+
"id": 5,
46+
"name": "__get",
47+
"kind": 524288,
48+
"kindString": "Get signature",
49+
"flags": {},
50+
"type": {
51+
"type": "instrinct",
52+
"name": "string"
53+
}
54+
}
55+
],
56+
"setSignature": [
57+
{
58+
"id": 6,
59+
"name": "__set",
60+
"kind": 1048576,
61+
"kindString": "Set signature",
62+
"flags": {},
63+
"parameters": [
64+
{
65+
"id": 7,
66+
"name": "value",
67+
"kind": 32768,
68+
"kindString": "Parameter",
69+
"flags": {},
70+
"type": {
71+
"type": "instrinct",
72+
"name": "string"
73+
}
74+
}
75+
],
76+
"type": {
77+
"type": "instrinct",
78+
"name": "string"
79+
}
80+
}
81+
]
82+
},
83+
{
84+
"id": 8,
85+
"name": "readOnlyName",
86+
"kind": 262144,
87+
"kindString": "Accessor",
88+
"flags": {},
89+
"getSignature": [
90+
{
91+
"id": 9,
92+
"name": "__get",
93+
"kind": 524288,
94+
"kindString": "Get signature",
95+
"flags": {},
96+
"type": {
97+
"type": "instrinct",
98+
"name": "string"
99+
}
100+
}
101+
]
102+
},
103+
{
104+
"id": 10,
105+
"name": "writeOnlyName",
106+
"kind": 262144,
107+
"kindString": "Accessor",
108+
"flags": {},
109+
"setSignature": [
110+
{
111+
"id": 11,
112+
"name": "__set",
113+
"kind": 1048576,
114+
"kindString": "Set signature",
115+
"flags": {},
116+
"parameters": [
117+
{
118+
"id": 12,
119+
"name": "value",
120+
"kind": 32768,
121+
"kindString": "Parameter",
122+
"flags": {},
123+
"type": {
124+
"type": "instrinct",
125+
"name": "string"
126+
}
127+
}
128+
],
129+
"type": {
130+
"type": "instrinct",
131+
"name": "string"
132+
}
133+
}
134+
]
135+
}
136+
],
137+
"groups": [
138+
{
139+
"title": "Properties",
140+
"kind": 1024,
141+
"children": [
142+
3
143+
]
144+
},
145+
{
146+
"title": "Accessors",
147+
"kind": 262144,
148+
"children": [
149+
4,
150+
8,
151+
10
152+
]
153+
}
154+
]
155+
}
156+
],
157+
"groups": [
158+
{
159+
"title": "Classes",
160+
"kind": 128,
161+
"children": [
162+
2
163+
]
164+
}
165+
]
166+
}
167+
],
168+
"groups": [
169+
{
170+
"title": "External modules",
171+
"kind": 1,
172+
"children": [
173+
1
174+
]
175+
}
176+
]
177+
}

0 commit comments

Comments
 (0)