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