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