forked from bitovi/documentjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathattribute.js
61 lines (56 loc) · 1.68 KB
/
attribute.js
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
61
/**
* @hide
* Documents an attribute. Example:
* @codestart
* steal.Object.extend(Person, {
* /* Number of People *|
* count: 0
* })
* @codeend
*/
DocumentJS.Pair.extend('DocumentJS.Attribute',
/* @static */
{
init : function(){
this.add(DocumentJS.Directive.Return, DocumentJS.Directive.Param, DocumentJS.Directive.CodeStart,
DocumentJS.Directive.CodeEnd,DocumentJS.Directive.Plugin, DocumentJS.Directive.Hide,
DocumentJS.Directive.Tag, DocumentJS.Directive.iFrame, DocumentJS.Directive.Demo,
DocumentJS.Directive.Parent, DocumentJS.Directive.Type, DocumentJS.Directive.Download,
DocumentJS.Directive.Test);
this._super();
this.serialize('plugin',['full_name','name'], 'html', 'shortName', 'ret','params',
['real_comment','comment'],'download','test')
},
/**
* Matches an attribute with code
* @param {Object} code
*/
code_match: function(code){
return code.match(/(\w+)\s*[:=]\s*/) && !code.match(/(\w+)\s*[:=]\s*function\(([^\)]*)/)
}
},
/* @prototype */
{
/**
* Saves the name of the attribute
*/
code_setup: function(){
var parts = this.code.match(/(\w+)\s*[:=]\s*/);
this.name = parts[1];
},
attribute_add: function(line){
var m = line.match(/^@\w+ ([^\s]+)/)
if(m){
this.name = m[1];
}
},
toFile : function(name){
try{
var res = this.jsonp();
new steal.File('apps/'+name+'/docs/'+this.full_name()+".json").save(res);
}catch(e ){
print("Unable to generate class for "+this.full_name()+" !")
print(" Error: "+e)
}
}
});