4 * Documentation - designed to generate HTML+Docbook!?!
6 Roo.doc = Roo.doc || {};
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.
17 * @param {Object} config The config object
22 Roo.doc.Entry = function(config){
23 Roo.doc.Entry.superclass.constructor.call(this, config);
24 //this.el = Roo.get(document.body);
26 var body = Roo.get(document.body);
36 // call onRender once... and block next call...?
39 //this.onRender = function() { };
44 //Roo.doc.Entry._calls = 0;
46 Roo.extend(Roo.doc.Entry, Roo.bootstrap.Component, {
52 getAutoCreate : function(){
73 addxtype : function (tree, cntr)
75 return this.addxtypeChild(tree,cntr);
78 onRender : function(ct, position)
81 Roo.doc.Entry._calls++;
82 if (Roo.doc.Entry._calls > 1 || !ct) {
86 // call onRender once... and block next call...?
88 Roo.bootstrap.Component.prototype.onRender.call(this, ct, position);
102 * @class Roo.doc.Example
103 * @extends Roo.bootstrap.Component
104 * Example Element class
105 * @cfg {String} title short title describing example
106 * @cfg {String} lang (php|txt|sql) section type.
107 * @cfg {String} code example code
108 * @cfg {String} output The expected output from the code
112 * Create a new Synopsis
113 * @param {Object} config The config object
116 Roo.doc.Example = function(config){
117 Roo.doc.Example.superclass.constructor.call(this, config);
120 Roo.extend(Roo.doc.Example, Roo.bootstrap.Component, {
128 getAutoCreate : function(){
130 // no colour highlighting in here....
132 var code = hljs ? hljs.highlight(this.lang,this.code).value :
133 String.format('{0}',this.code).replace(/\n/g, '<br/>');
137 cls : 'panel panel-info',
140 cls : 'panel-heading',
148 cls : 'lang-' + this.lang,
158 var out = hljs ? hljs.highlight(this.outputlang,this.output).value :
159 String.format('{0}',this.output).replace(/\n/g, '<br/>');
163 cls : 'panel-footer',
192 * @class Roo.doc.Para
193 * @extends Roo.bootstrap.Component
194 * Param Element class
198 * Create a new Paragraph
199 * @param {Object} config The config object
202 Roo.doc.Para = function(config){
203 Roo.doc.Para.superclass.constructor.call(this, config);
206 Roo.extend(Roo.doc.Para, Roo.bootstrap.Component, {
209 getAutoCreate : function(){
211 //?? this is the synopsis type....
213 // this is not very fancy...
221 if (this.parent().is_list) {
248 * @class Roo.doc.Param
249 * @extends Roo.bootstrap.Component
250 * Param Element class
251 * @cfg {bool} is_optional is the argument optional
252 * @cfg {String} type argument type
253 * @cfg {String} name name of the parameter
254 * @cfg {String} desc short description
255 * @cfg {String} defaultvalue default value
259 * @param {Object} config The config object
262 Roo.doc.Param = function(config){
263 Roo.doc.Param.superclass.constructor.call(this, config);
266 Roo.extend(Roo.doc.Param, Roo.bootstrap.Component, {
274 getAutoCreate : function(){
276 //?? this is the synopsis type....
279 if (this.parent().stype == 'parameter') {
290 html : this.type + ' ' + this.name
299 if (this.parent().stype == 'return') {
316 // this is not very fancy...
321 this.is_optional ? '[' : '',
328 this.defaultvalue == '' ? '' : ' = ',
330 this.is_optional ? ']' : '',
331 ',' // not really.. but let's do it anyway...
340 getAutoCreateParamSection : function()
351 html : this.type + ' ' + this.name
378 * @class Roo.doc.Section
379 * @extends Roo.bootstrap.Component
380 * SectionElement class
381 * @cfg {String} stype (desc|parameter|return|note|example) section type.
384 * Create a new Synopsis
385 * @param {Object} config The config object
388 Roo.doc.Section = function(config){
389 Roo.doc.Section.superclass.constructor.call(this, config);
392 Roo.extend(Roo.doc.Section, Roo.bootstrap.Component, {
397 getAutoCreate : function(){
400 var syn = Roo.factory(this.parent().items[0]);
410 html : Roo.doc.Section.map[this.stype]
414 if (this.stype == 'parameter') {
416 // db package uses variable list here... - it results in dd/dl but the layout is messed up..
420 cls: 'itemizedlist roo-params',
423 // might not have any..
424 var params = syn.items;
425 for (var i =0; i < params.length;i++) {
426 ul.cn.push( Roo.factory(params[i]).getAutoCreateParamSection() )
432 if (this.stype == 'return' && syn.returndesc.length) {
442 html : syn.returntype
452 getChildContainer : function(build_call)
455 if (this.stype == 'parameter') {
456 return this.el.select('.roo-params',true).first();
467 Roo.doc.Section.map = {
468 'desc' : 'Description',
469 'parameter' : 'Parameters',
470 'return' : 'Return Value',
472 'example' : 'Examples'
480 * @class Roo.doc.Synopsis
481 * @extends Roo.bootstrap.Component
482 * Synopsis Element class
483 * @cfg {String} returntype return value
484 * @cfg {String} returndesc description of return value. (used in the return section if set..)
485 * @cfg {String} name title really..
486 * @cfg {String} stype (function|constant)
487 * @cfg {String} memberof class name
488 * @cfg {bool} is_static is a static member
491 * Create a new Synopsis
492 * @param {Object} config The config object
495 Roo.doc.Synopsis = function(config){
496 Roo.doc.Synopsis.superclass.constructor.call(this, config);
499 Roo.extend(Roo.doc.Synopsis, Roo.bootstrap.Component, {
508 getAutoCreate : function(){
510 var syn = this.items[0]; // hopefully...
514 var nmp = (this.is_static ? '' : '$') +
516 (this.is_static ? '::' : '->');
519 // this should probably do the params....?? then we need to disable the rendering..
524 cls : 'refsynopsisdiv',
533 cls : 'funcprototype',
535 this.returntype + ' ' + nmp,
561 getChildContainer : function(build_call)
565 return this.el.select('.roo-params',true).first();
582 * @class Roo.doc.NavCategory
583 * @extends Roo.bootstrap.Component
584 * Navigation Category class
585 * @cfg {string} title
588 * Represent's an category on the left menu.
589 * - phpdoc @category elements map the pages to the categories
590 * this should be on the left side of the menu, when the
591 * contents are loaded, then it can expand this out, and add links
592 * for each of the methods.
597 * Create a new Navigation Category
598 * @param {Object} config The config object
601 Roo.doc.NavCategory = function(config){
602 Roo.doc.Para.superclass.constructor.call(this, config);
603 Roo.doc.NavCategory.registry[this.name] = this;
605 Roo.doc.NavCategory.registry = {};
606 Roo.extend(Roo.doc.NavCategory, Roo.bootstrap.Component, {
610 getAutoCreate : function(){
612 //?? this is the synopsis type....
614 // this is not very fancy...
622 cls: 'roo-nav-category',
623 href : '#' + this.name,
627 cls : 'container roo-child-ctr'
634 getChildContainer : function()
636 return this.el.select('.roo-child-ctr',true).first();