-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experimental): class properties
- Loading branch information
1 parent
e2689dd
commit c7b4d9b
Showing
8 changed files
with
170 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import AbstractDoc from './AbstractDoc.js'; | ||
import MethodDoc from './MethodDoc.js'; | ||
import ParamParser from '../Parser/ParamParser.js'; | ||
|
||
/** | ||
* Doc Class from ClassProperty AST node. | ||
*/ | ||
export default class ClassPropertyDoc extends AbstractDoc { | ||
/** | ||
* apply own tag. | ||
* @private | ||
*/ | ||
_apply() { | ||
super._apply(); | ||
|
||
Reflect.deleteProperty(this._value, 'export'); | ||
Reflect.deleteProperty(this._value, 'importPath'); | ||
Reflect.deleteProperty(this._value, 'importStyle'); | ||
} | ||
|
||
/** specify ``member`` to kind. */ | ||
_$kind() { | ||
super._$kind(); | ||
this._value.kind = 'member'; | ||
} | ||
|
||
/** take out self name from self node */ | ||
_$name() { | ||
super._$name(); | ||
this._value.name = this._node.key.name; | ||
} | ||
|
||
/** borrow {@link MethodDoc#@_memberof} */ | ||
_$memberof() { | ||
Reflect.apply(MethodDoc.prototype._$memberof, this, []); | ||
} | ||
|
||
/** if @type is not exists, guess type by using self node */ | ||
_$type() { | ||
super._$type(); | ||
if (this._value.type) return; | ||
|
||
this._value.type = ParamParser.guessType(this._node.value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* this is TestClassPropertyDefinition. | ||
* @todo test `Access`, `Deprecated`, `Desc`, `Duplication`, `Example`, `Experimental`, `Guess`, `Ignore`, `Link`, `See`, `Since`, `Todo` and `Version`. | ||
*/ | ||
export default class TestClassPropertyDefinition { | ||
/** | ||
* this is static p1. | ||
* @type {number} | ||
*/ | ||
static p1 = 123; | ||
|
||
/** | ||
* this is p1. | ||
* @type {number} | ||
*/ | ||
p1 = 123; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/src/HTMLTest/DocumentTest/ClassPropertyTest/DefinitionTest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import {readDoc, assert, find} from './../../../util.js'; | ||
|
||
/** @test {ClassDocBuilder} */ | ||
describe('TestClassPropertyDefinition:', ()=> { | ||
const doc = readDoc('class/src/ClassProperty/Definition.js~TestClassPropertyDefinition.html'); | ||
|
||
/** @test {ClassDocBuilder#_buildClassDoc} */ | ||
describe('in summary', ()=>{ | ||
it('has static member', ()=>{ | ||
find(doc, '[data-ice="staticMemberSummary"]', (doc)=>{ | ||
find(doc, 'table[data-ice="summary"]:nth-of-type(1)', (doc)=>{ | ||
assert.includes(doc, '[data-ice="target"]:nth-of-type(1)', 'public static p1: number this is static p1.'); | ||
assert.includes(doc, '[data-ice="target"]:nth-of-type(1) [data-ice="name"] a', 'class/src/ClassProperty/Definition.js~TestClassPropertyDefinition.html#static-member-p1', 'href'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('has member.', ()=>{ | ||
find(doc, '[data-ice="memberSummary"]', (doc)=>{ | ||
find(doc, 'table[data-ice="summary"]:nth-of-type(1)', (doc)=> { | ||
assert.includes(doc, '[data-ice="target"]:nth-of-type(1)', 'public p1: number this is p1.'); | ||
assert.includes(doc, '[data-ice="target"]:nth-of-type(1) [data-ice="name"] a', 'class/src/ClassProperty/Definition.js~TestClassPropertyDefinition.html#instance-member-p1', 'href'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
/** @test {ClassDocBuilder#_buildClassDoc} */ | ||
describe('in detail', ()=>{ | ||
it('has static member.', ()=>{ | ||
find(doc, '[data-ice="staticMemberDetails"]', (doc)=>{ | ||
find(doc, '[data-ice="detail"]:nth-of-type(1)', (doc)=>{ | ||
assert.includes(doc, '#static-member-p1', 'public static p1: number'); | ||
assert.includes(doc, '[data-ice="description"]', 'this is static p1.'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('has member.', ()=>{ | ||
find(doc, '[data-ice="memberDetails"]', (doc)=>{ | ||
find(doc, '[data-ice="detail"]:nth-of-type(1)', (doc)=>{ | ||
assert.includes(doc, '#instance-member-p1', 'public p1: number'); | ||
assert.includes(doc, '#instance-member-p1 + [data-ice="description"]', 'this is p1.'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |