forked from bitovi/documentjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpage.js
107 lines (99 loc) · 2.93 KB
/
page.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* @hide
* Documents a 'Class'. A class is typically a collection of static and prototype functions.
* steal Doc can automatically detect classes created with steal.Class. However, you can make anything
* a class with the <b>@class <i>ClassName</i></b> directive.
* @author Jupiter IT
* @codestart
* /**
* * Person represents a human with a name. Read about the
* * animal class [Animal | here].
* * @init
* * You must pass in a name.
* * @params {String} name A person's name
* *|
* Person = Animal.extend(
* /* @Static *|
* {
* /* Number of People *|
* count: 0
* },
* /* @Prototype *|
* {
* init : function(name){
* this.name = name
* this._super({warmblood: true})
* },
* /* Returns a formal name
* * @return {String} the name with "Mrs." added
* *|
* fancy_name : function(){
* return "Mrs. "+this.name;
* }
* })
* @codeend
*/
DocumentJS.Pair.extend('DocumentJS.Page',
/* @Static */
{
starts_scope: true,
listing: [],
/**
* Loads the class view.
*/
init : function(){
this.add(
DocumentJS.Directive.CodeStart, DocumentJS.Directive.CodeEnd,
DocumentJS.Directive.Tag, DocumentJS.Directive.iFrame, DocumentJS.Directive.Demo, DocumentJS.Directive.Parent)
this._super();
var ejs = "jmvc/plugins/documentation/templates/file.ejs"
this.serialize("name",['real_comment','comment'],"shortName","title",['linker','children'])
}
},
/* @Prototype */
{
/**
* Verifies the class was created successfully.
*/
comment_setup_complete : function(){
if(!this.name){
print("Error! No name defined for \n-----------------------")
print(this.comment)
print('-----------------------')
}
},
code_setup: function(){
},
page_add: function(line){
var m = line.match(/^@\w+\s+([^\s]+)\s+(.+)/)
if(m){
this.name = m[1];
this.title = m[2] || this.name;
}
},
/**
* Renders this class to a file.
* @param {String} left_side The left side content / list of all documented classes & constructors.
*/
toFile : function(name){
try{
var res = this.jsonp();
new steal.File('apps/'+name+'/docs/'+this.name.replace(/ /g,"_")+".json").save(res);
}catch(e ){
print("Unable to generate class for "+this.name+" !")
print(" Error: "+e)
}
},
cleaned_comment : function(){
return DocumentJS.link_content(this.real_comment).replace(/\n\s*\n/g,"<br/><br/>");
},
full_name : function(){
return this.name;
},
add_parent : function(scope){
//always go back to the file:
while(scope.Class.shortName.toLowerCase() != 'script') scope = scope.parent;
this.parent = scope.children.length ? scope.children[0] : scope;
this.parent.add(this);
}
});