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                 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         var cfg ={
338             
339             cls : 'refsection',
340             // id... ?
341             cn : [
342                 {
343                     tag: 'h1',
344                     cls : 'title',
345                     html : this.stype.charAt(0).toUpperCase() + this.stype.slice(1) //ucfirst
346                 }
347             ]
348         };
349         if (this.stype == 'parameter') {
350             
351             // db package uses variable list here... - it results in dd/dl but the layout is messed up..
352             cfg.cn.push({
353                 tag: 'ul',
354                 cls: 'itemizedlist roo-params'
355             });
356         }
357         
358         
359         return cfg;
360     },
361     getChildContainer : function(build_call)
362     {
363          
364         if (this.stype == 'parameter') {
365             return this.el.select('.roo-params',true).first();
366         }
367         return this.el;
368     }
369     
370     
371    
372 });
373
374  
375
376  /*
377  * - LGPL
378  *
379  */
380
381 /**
382  * @class Roo.doc.Synopsis
383  * @extends Roo.bootstrap.Component
384  * Synopsis Element class
385  * @cfg {String} returntype return value
386  * @cfg {String} name title really..
387  * @cfg {String} stype (function|constant)
388  * 
389  * @constructor
390  * Create a new Synopsis
391  * @param {Object} config The config object
392  */
393
394 Roo.doc.Synopsis = function(config){
395     Roo.doc.Synopsis.superclass.constructor.call(this, config);
396 };
397
398 Roo.extend(Roo.doc.Synopsis, Roo.bootstrap.Component,  {
399     
400     
401     returntype : '',
402     name: '',
403     stype:   'function',
404      
405     getAutoCreate : function(){
406         
407         var cfg ={
408             tag: 'h2',
409             cls : 'refsynopsisdiv',
410             cn : [
411                 {
412                     cls: 'funcsynopsis',
413                     cn: [
414                         {
415                             tag: 'p',
416                             cn: {
417                                 tag:'code',
418                                 cls : 'funcprototype',
419                                 cn: [
420                                     this.returntype + ' ',
421                                     {
422                                         tag: 'strong',
423                                         cls : this.stype,
424                                         html : this.name
425                                     },
426                                     '(',
427                                     {
428                                         tag: 'span',
429                                         cls : 'roo-params'
430                                     },
431                                     ')'
432                                 ]
433                                 
434                             }
435                         }
436                     ]
437                 }
438                 
439             ]
440         };
441         
442         
443         
444         return cfg;
445     },
446     getChildContainer : function(build_call)
447     {
448          
449         
450         return this.el.select('.roo-params',true).first();
451     }
452     
453     
454     
455     
456    
457 });
458
459  
460
461