Roo/doc/Param.js
[roojs1] / Roo / doc / Param.js
1 /*
2  * - LGPL
3  *
4  */
5
6 /**
7  * @class Roo.doc.Param
8  * @extends Roo.bootstrap.Component
9  * Param Element class
10  * @cfg {bool} is_optional is the argument optional
11  * @cfg {String} type  argument type
12  * @cfg {String} name name of the parameter
13  * @cfg {String} desc  short description
14  * @cfg {String} defaultvalue default value
15  * 
16  * @constructor
17  * Create a new Param
18  * @param {Object} config The config object
19  */
20
21 Roo.doc.Param = function(config){
22     Roo.doc.Param.superclass.constructor.call(this, config);
23 };
24
25 Roo.extend(Roo.doc.Param, Roo.bootstrap.Component,  {
26     
27     is_optional : false,
28     type : '',
29     name: '',
30     defaultvalue:   '',
31     desc: '',
32      
33     getAutoCreate : function(){
34         
35         //?? this is the synopsis type....
36         
37         var desc = Roo.Markdown.toHtml(this.desc);
38         
39         if (this.parent().stype == 'parameter') {
40             
41             return {
42                 tag : 'li',
43                 cn : [
44                     {
45                         tag : 'p',
46                         cls: 'para',
47                         cn : [
48                             {
49                                 tag: 'code',
50                                 html : this.type + ' ' + this.name
51                             },
52                             desc
53                         ]
54                     }
55                 ]
56             };
57             
58         }
59          if (this.parent().stype == 'return') {
60             return {
61                     tag : 'p',
62                     cls: 'para',
63                     cn : [
64                         {
65                             tag: 'code',
66                             html : this.type
67                         },
68                         desc
69                     ]
70                 };
71                 
72          }
73        
74         
75         
76         // this is not very fancy...
77         
78         var cfg ={
79             tag: 'span',
80             cn : [
81                 this.is_optional ? '[' : '',
82                 this.type,
83                 ' ',
84                 {
85                     tag : 'b',
86                     html : this.name
87                 },
88                 this.defaultvalue == '' ? '' : ' = ',
89                 this.defaultvalue,
90                 this.is_optional ? ']' : '',
91                 ',' // not really.. but let's do it anyway...
92             ]
93         };
94          
95         
96         
97         
98         return cfg;
99     },
100     getAutoCreateParamSection : function()
101     {
102         var desc = Roo.Markdown.toHtml(this.desc);
103         
104       
105         return {
106                tag : 'li',
107                cn : [
108                    {
109                        tag : 'p',
110                        cls: 'para',
111                        cn : [
112                            {
113                                tag: 'code',
114                                html : this.type + ' ' + this.name
115                            },
116                            desc
117                        ]
118                    }
119                ]
120            };
121         
122         
123     }
124     
125      
126     
127     
128     
129     
130    
131 });
132
133  
134
135