forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproptomember.js
More file actions
executable file
·60 lines (47 loc) · 1.64 KB
/
Copy pathproptomember.js
File metadata and controls
executable file
·60 lines (47 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* Transform @property tags to @member tags if it looks like @property was incorrectly used.
* - That is, there is only one property and it has the same name as the member.
* The result is less-redundancy and better type exposure in the JSDoc output.
*
* If the member type is not assigned then the property type is used.
*
* A meld of the description are used; appending the property description if appropriate.
*
* This approach works for most cases in Phaser because JSDoc automatically determines the name if not specified in @name, @method, @member or @field.
*/
var path = require('path');
function looksLikeItMightContain (haystack, needle) {
haystack = haystack || '';
needle = needle || '';
haystack = haystack.replace(/[^a-z]/gi, '').toLowerCase();
needle = needle.replace(/[^a-z]/gi, '').toLowerCase();
return haystack.indexOf(needle) > -1;
}
exports.handlers = {};
exports.handlers.newDoclet = function (e) {
var doclet = e.doclet;
var props = e.doclet.properties;
if (doclet.kind === 'member' &&
props && props.length === 1 &&
props[0].name === doclet.name)
{
// "Duplicate"
var prop = props[0];
if (!doclet.type)
{
doclet.type = prop.type;
}
if (!doclet.description)
{
doclet.description = prop.description;
}
else if (prop.description &&
!looksLikeItMightContain(doclet.description, prop.description))
{
// Tack it on..
doclet.description += " " + prop.description;
}
// And no more prop
e.doclet.properties = undefined;
}
};