roojs-doc.js
[roojs1] / roojs-doc-debug.js
1 /*
2  * - LGPL
3  *
4  *  Documentation - designed to generate HTML+Docbook!?!
5  */
6 Roo.doc = Roo.doc || {};
7
8 /**
9  * @class Roo.doc.Entry
10  * @extends Roo.bootstrap.Component
11  * Entry Element class - describes a method etc...
12  * @cfg name {String} name of method
13  * @cfg purpose {String} short description of method.
14  * 
15  * @constructor
16  * Create a new E
17  * @param {Object} config The config object
18  */
19
20
21
22 Roo.doc.Entry  = function(config){
23     Roo.doc.Entry.superclass.constructor.call(this, config);
24     //this.el = Roo.get(document.body);
25     var body = Roo.get(document.body);
26     body.attr({
27         leftmargin : 0,
28         marginwidth : 0,
29         topmargin : 0,
30         marginheight : 0,
31         offset : 0
32     });
33     
34      
35     // call onRender once... and block next call...?
36     this.onRender(body);
37     this.el = body;
38     //this.onRender = function() { };
39
40 };
41
42 Roo.doc.Entry._calls = 0;
43
44 Roo.extend(Roo.doc.Entry, Roo.bootstrap.Component,  {
45     
46     
47     name : '',
48     purpose : '',
49     
50     getAutoCreate : function(){
51         
52         var cfg ={
53             cls : 'refentry',
54             cn : [
55                 {
56                     tag: 'h1',
57                     cls: 'refname',
58                     html : this.name
59                 },
60                 {
61                     cls: 'refnamediv',
62                     html : this.purpose
63                 }
64             ]
65         };
66         
67         
68          
69         
70         return cfg;
71     },
72     
73     addxtype :   function (tree, cntr)
74     {
75         return this.addxtypeChild(tree,cntr);
76     },
77     
78     onRender : function(ct, position)
79     {
80         
81         Roo.doc.Entry._calls++;
82         if (Roo.doc.Entry._calls > 1 || !ct) {
83             return;
84         }
85         
86     // call onRender once... and block next call...?
87     
88         Roo.bootstrap.Component.prototype.onRender.call(this, ct, position);
89     }
90    
91 });
92
93  
94
95  /*
96  * - LGPL
97  *
98  */
99
100 /**
101  * @class Roo.doc.Example
102  * @extends Roo.bootstrap.Component
103  * Example Element class
104  * @cfg {String} lang (phpcode|programlisting) section type.
105  * @cfg {String} code
106  *
107  * 
108  * @constructor
109  * Create a new Synopsis
110  * @param {Object} config The config object
111  */
112
113 Roo.doc.Example = function(config){
114     Roo.doc.Example.superclass.constructor.call(this, config);
115 };
116
117 Roo.extend(Roo.doc.Example, Roo.bootstrap.Component,  {
118     
119     
120     lang:   'php',
121     code : '',
122     
123     getAutoCreate : function(){
124         
125         // no colour highlighting in here....
126         
127         var cfg ={
128             
129             cls : this.lang,
130             
131             cn : [
132                 {
133                     tag: 'code',
134                     html :  String.format('{0}',this.code).replace(/\n/g, '<br/>')
135                 }
136             ]
137         };
138         
139         
140         return cfg;
141     }
142   
143     
144     
145    
146 });
147
148  
149
150  /*
151  * - LGPL
152  *
153  */
154
155 /**
156  * @class Roo.doc.Para
157  * @extends Roo.bootstrap.Component
158  * Param Element class
159  * @cfg {String} html
160  * 
161  * @constructor
162  * Create a new Paragraph
163  * @param {Object} config The config object
164  */
165
166 Roo.doc.Para = function(config){
167     Roo.doc.Para.superclass.constructor.call(this, config);
168 };
169
170 Roo.extend(Roo.doc.Para, Roo.bootstrap.Component,  {
171     
172     html : '',
173     getAutoCreate : function(){
174         
175         //?? this is the synopsis type....
176         
177         // this is not very fancy...
178         
179         var cfg ={
180             tag: 'p',
181             cls: 'para',
182             html : this.html
183         };
184          
185         if (this.parent().is_list) {
186             return {
187                 tag: 'li',
188                 cls : listitme,
189                 cn : [ cfg ]
190             };
191             
192         }
193         
194         return cfg;
195     }
196      
197     
198     
199     
200     
201    
202 });
203
204  
205
206  /*
207  * - LGPL
208  *
209  */
210
211 /**
212  * @class Roo.doc.Param
213  * @extends Roo.bootstrap.Component
214  * Param Element class
215  * @cfg {bool} is_optional is the argument optional
216  * @cfg {String} type  argument type
217  * @cfg {String} name name of the parameter
218  * @cfg {String} desc  short description
219  * @cfg {String} defaultvalue default value
220  * 
221  * @constructor
222  * Create a new Param
223  * @param {Object} config The config object
224  */
225
226 Roo.doc.Param = function(config){
227     Roo.doc.Param.superclass.constructor.call(this, config);
228 };
229
230 Roo.extend(Roo.doc.Param, Roo.bootstrap.Component,  {
231     
232     is_optional : false,
233     type : '',
234     name: '',
235     defaultvalue:   '',
236     desc: '',
237      
238     getAutoCreate : function(){
239         
240         //?? this is the synopsis type....
241         
242         
243         if (this.parent().stype == 'parameter') {
244             
245             return {
246                 tag : 'li',
247                 cn : [
248                     {
249                         tag : 'p',
250                         cls: 'para',
251                         cn : [
252                             {
253                                 tag: 'code',
254                                 html : this.type + ' ' + this.name
255                             },
256                             this.desc
257                         ]
258                     }
259                 ]
260             };
261             
262         }
263          if (this.parent().stype == 'return') {
264             return {
265                     tag : 'p',
266                     cls: 'para',
267                     cn : [
268                         {
269                             tag: 'code',
270                             html : this.type
271                         },
272                         this.desc
273                     ]
274                 };
275                 
276          }
277        
278         
279         
280         // this is not very fancy...
281         
282         var cfg ={
283             tag: 'span',
284             cn : [
285                 this.is_optional ? '[' : '',
286                 this.type,
287                 ' ',
288                 this.name,
289                 this.defaultvalue == '' ? '' : ' = ',
290                 this.defaultvalue,
291                 ',' // not really.. but let's do it anyway...
292             ]
293         };
294          
295         
296         
297         
298         return cfg;
299     }
300      
301     
302     
303     
304     
305    
306 });
307
308  
309
310  /*
311  * - LGPL
312  *
313  */
314
315 /**
316  * @class Roo.doc.Section
317  * @extends Roo.bootstrap.Component
318  * SectionElement class
319  * @cfg {String} stype (desc|parameter|return|note|example) section type.
320  * 
321  * @constructor
322  * Create a new Synopsis
323  * @param {Object} config The config object
324  */
325
326 Roo.doc.Section = function(config){
327     Roo.doc.Section.superclass.constructor.call(this, config);
328 };
329
330 Roo.extend(Roo.doc.Section, Roo.bootstrap.Component,  {
331     
332     
333     stype:   '',
334      
335     getAutoCreate : function(){
336         
337         
338         
339         
340         var cfg ={
341             
342             cls : 'refsection',
343             // id... ?
344             cn : [
345                 {
346                     tag: 'h1',
347                     cls : 'title',
348                     html : Roo.doc.Section.map[this.stype] 
349                 }
350             ]
351         };
352         if (this.stype == 'parameter') {
353             
354             // db package uses variable list here... - it results in dd/dl but the layout is messed up..
355             cfg.cn.push({
356                 tag: 'ul',
357                 cls: 'itemizedlist roo-params'
358             });
359         }
360         
361         
362         return cfg;
363     },
364     getChildContainer : function(build_call)
365     {
366          
367         if (this.stype == 'parameter') {
368             return this.el.select('.roo-params',true).first();
369         }
370         return this.el;
371     }
372     
373     
374    
375 });
376
377  
378 Roo.doc.Section.map = {
379     'desc' : 'Description',
380     'parameter' : 'Parameters',
381     'return' : 'Return Value',
382     'note' : 'Notes',
383     'example' : 'Examples'
384 }
385 /*
386  * - LGPL
387  *
388  */
389
390 /**
391  * @class Roo.doc.Synopsis
392  * @extends Roo.bootstrap.Component
393  * Synopsis Element class
394  * @cfg {String} returntype return value
395  * @cfg {String} name title really..
396  * @cfg {String} stype (function|constant)
397  * 
398  * @constructor
399  * Create a new Synopsis
400  * @param {Object} config The config object
401  */
402
403 Roo.doc.Synopsis = function(config){
404     Roo.doc.Synopsis.superclass.constructor.call(this, config);
405 };
406
407 Roo.extend(Roo.doc.Synopsis, Roo.bootstrap.Component,  {
408     
409     
410     returntype : '',
411     name: '',
412     stype:   'function',
413      
414     getAutoCreate : function(){
415         
416         var cfg ={
417             tag: 'h2',
418             cls : 'refsynopsisdiv',
419             cn : [
420                 {
421                     cls: 'funcsynopsis',
422                     cn: [
423                         {
424                             tag: 'p',
425                             cn: {
426                                 tag:'code',
427                                 cls : 'funcprototype',
428                                 cn: [
429                                     this.returntype + ' ',
430                                     {
431                                         tag: 'strong',
432                                         cls : this.stype,
433                                         html : this.name
434                                     },
435                                     '(',
436                                     {
437                                         tag: 'span',
438                                         cls : 'roo-params'
439                                     },
440                                     ')'
441                                 ]
442                                 
443                             }
444                         }
445                     ]
446                 }
447                 
448             ]
449         };
450         
451         
452         
453         return cfg;
454     },
455     getChildContainer : function(build_call)
456     {
457          
458         
459         return this.el.select('.roo-params',true).first();
460     }
461     
462     
463     
464     
465    
466 });
467
468  
469
470