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