Roo/doc/Param.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                 {
289                     tag : 'b',
290                     html : this.name
291                 },
292                 this.defaultvalue == '' ? '' : ' = ',
293                 this.defaultvalue,
294                 this.is_optional ? ']' : '',
295                 ',' // not really.. but let's do it anyway...
296             ]
297         };
298          
299         
300         
301         
302         return cfg;
303     }
304      
305     
306     
307     
308     
309    
310 });
311
312  
313
314  /*
315  * - LGPL
316  *
317  */
318
319 /**
320  * @class Roo.doc.Section
321  * @extends Roo.bootstrap.Component
322  * SectionElement class
323  * @cfg {String} stype (desc|parameter|return|note|example) section type.
324  * 
325  * @constructor
326  * Create a new Synopsis
327  * @param {Object} config The config object
328  */
329
330 Roo.doc.Section = function(config){
331     Roo.doc.Section.superclass.constructor.call(this, config);
332 };
333
334 Roo.extend(Roo.doc.Section, Roo.bootstrap.Component,  {
335     
336     
337     stype:   '',
338      
339     getAutoCreate : function(){
340         
341         
342         
343         
344         var cfg ={
345             
346             cls : 'refsection',
347             // id... ?
348             cn : [
349                 {
350                     tag: 'h1',
351                     cls : 'title',
352                     html : Roo.doc.Section.map[this.stype] 
353                 }
354             ]
355         };
356         if (this.stype == 'parameter') {
357             
358             // db package uses variable list here... - it results in dd/dl but the layout is messed up..
359             cfg.cn.push({
360                 tag: 'ul',
361                 cls: 'itemizedlist roo-params'
362             });
363         }
364         
365         
366         return cfg;
367     },
368     getChildContainer : function(build_call)
369     {
370          
371         if (this.stype == 'parameter') {
372             return this.el.select('.roo-params',true).first();
373         }
374         return this.el;
375     }
376     
377     
378    
379 });
380
381  
382 Roo.doc.Section.map = {
383     'desc' : 'Description',
384     'parameter' : 'Parameters',
385     'return' : 'Return Value',
386     'note' : 'Notes',
387     'example' : 'Examples'
388 }
389 /*
390  * - LGPL
391  *
392  */
393
394 /**
395  * @class Roo.doc.Synopsis
396  * @extends Roo.bootstrap.Component
397  * Synopsis Element class
398  * @cfg {String} returntype return value
399  * @cfg {String} name title really..
400  * @cfg {String} stype (function|constant)
401  * 
402  * @constructor
403  * Create a new Synopsis
404  * @param {Object} config The config object
405  */
406
407 Roo.doc.Synopsis = function(config){
408     Roo.doc.Synopsis.superclass.constructor.call(this, config);
409 };
410
411 Roo.extend(Roo.doc.Synopsis, Roo.bootstrap.Component,  {
412     
413     
414     returntype : '',
415     name: '',
416     stype:   'function',
417      
418     getAutoCreate : function(){
419         
420         var cfg ={
421             tag: 'h2',
422             cls : 'refsynopsisdiv',
423             cn : [
424                 {
425                     cls: 'funcsynopsis',
426                     cn: [
427                         {
428                             tag: 'p',
429                             cn: {
430                                 tag:'code',
431                                 cls : 'funcprototype',
432                                 cn: [
433                                     this.returntype + ' ',
434                                     {
435                                         tag: 'strong',
436                                         cls : this.stype,
437                                         html : this.name
438                                     },
439                                     '(',
440                                     {
441                                         tag: 'span',
442                                         cls : 'roo-params'
443                                     },
444                                     ')'
445                                 ]
446                                 
447                             }
448                         }
449                     ]
450                 }
451                 
452             ]
453         };
454         
455         
456         
457         return cfg;
458     },
459     getChildContainer : function(build_call)
460     {
461          
462         
463         return this.el.select('.roo-params',true).first();
464     }
465     
466     
467     
468     
469    
470 });
471
472  
473
474