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) code language.
107 * @cfg {String} code example code
108 * @cfg {String} output The expected output from the code
109 * @cfg {String} outputlang php|txt|sql) output language
113 * Create a new Synopsis
114 * @param {Object} config The config object
117 Roo.doc.Example = function(config){
118 Roo.doc.Example.superclass.constructor.call(this, config);
121 Roo.extend(Roo.doc.Example, Roo.bootstrap.Component, {
129 getAutoCreate : function(){
131 // no colour highlighting in here....
133 var code = hljs ? hljs.highlight(this.lang,this.code).value :
134 String.format('{0}',this.code).replace(/\n/g, '<br/>');
136 Roo.log("code=" + code);
138 cls : 'panel panel-info',
141 cls : 'panel-heading',
149 cls : 'lang-' + this.lang,
159 var out = hljs ? hljs.highlight(this.outputlang,this.output).value :
160 String.format('{0}',this.output).replace(/\n/g, '<br/>');
164 cls : 'panel-footer',
193 * @class Roo.doc.Para
194 * @extends Roo.bootstrap.Component
195 * Param Element class
199 * Create a new Paragraph
200 * @param {Object} config The config object
203 Roo.doc.Para = function(config){
204 Roo.doc.Para.superclass.constructor.call(this, config);
207 Roo.extend(Roo.doc.Para, Roo.bootstrap.Component, {
210 getAutoCreate : function(){
212 //?? this is the synopsis type....
214 // this is not very fancy...
219 html : Roo.Markdown.toHtml(this.html)
222 if (this.parent().is_list) {
249 * @class Roo.doc.Param
250 * @extends Roo.bootstrap.Component
251 * Param Element class
252 * @cfg {bool} is_optional is the argument optional
253 * @cfg {String} type argument type
254 * @cfg {String} name name of the parameter
255 * @cfg {String} desc short description
256 * @cfg {String} defaultvalue default value
260 * @param {Object} config The config object
263 Roo.doc.Param = function(config){
264 Roo.doc.Param.superclass.constructor.call(this, config);
267 Roo.extend(Roo.doc.Param, Roo.bootstrap.Component, {
275 getAutoCreate : function(){
277 //?? this is the synopsis type....
279 var desc = Roo.Markdown.toHtml(this.desc);
281 if (this.parent().stype == 'parameter') {
292 html : this.type + ' ' + this.name
301 if (this.parent().stype == 'return') {
318 // this is not very fancy...
323 this.is_optional ? '[' : '',
330 this.defaultvalue == '' ? '' : ' = ',
332 this.is_optional ? ']' : '',
333 ',' // not really.. but let's do it anyway...
342 getAutoCreateParamSection : function()
344 var desc = Roo.Markdown.toHtml(this.desc);
356 html : this.type + ' ' + this.name
383 * @class Roo.doc.Section
384 * @extends Roo.bootstrap.Component
385 * SectionElement class
386 * @cfg {String} stype (desc|parameter|return|note|example) section type.
389 * Create a new Synopsis
390 * @param {Object} config The config object
393 Roo.doc.Section = function(config){
394 Roo.doc.Section.superclass.constructor.call(this, config);
397 Roo.extend(Roo.doc.Section, Roo.bootstrap.Component, {
402 getAutoCreate : function(){
405 var syn = Roo.factory(this.parent().items[0]);
415 html : Roo.doc.Section.map[this.stype]
419 if (this.stype == 'parameter') {
421 // db package uses variable list here... - it results in dd/dl but the layout is messed up..
425 cls: 'itemizedlist roo-params',
428 // might not have any..
429 var params = syn.items;
430 for (var i =0; i < params.length;i++) {
431 ul.cn.push( Roo.factory(params[i]).getAutoCreateParamSection() )
437 if (this.stype == 'return' && syn.returndesc.length) {
447 html : syn.returntype
457 getChildContainer : function(build_call)
460 if (this.stype == 'parameter') {
461 return this.el.select('.roo-params',true).first();
472 Roo.doc.Section.map = {
473 'desc' : 'Description',
474 'parameter' : 'Parameters',
475 'return' : 'Return Value',
477 'example' : 'Examples'
485 * @class Roo.doc.Synopsis
486 * @extends Roo.bootstrap.Component
487 * Synopsis Element class
488 * @cfg {String} returntype return value
489 * @cfg {String} returndesc description of return value. (used in the return section if set..)
490 * @cfg {String} name title really..
491 * @cfg {String} stype (function|constant)
492 * @cfg {String} memberof class name
493 * @cfg {bool} is_static is a static member
494 * @cfg {bool} is_constructor is a static member
497 * Create a new Synopsis
498 * @param {Object} config The config object
501 Roo.doc.Synopsis = function(config){
502 Roo.doc.Synopsis.superclass.constructor.call(this, config);
505 Roo.extend(Roo.doc.Synopsis, Roo.bootstrap.Component, {
513 is_constructor : false,
515 getAutoCreate : function(){
517 var syn = this.items[0]; // hopefully...
521 var nmp = (this.is_static ? '' : '$') +
523 (this.is_static ? '::' : '->');
526 // this should probably do the params....?? then we need to disable the rendering..
528 if (this.is_constructor) {
537 cls : 'refsynopsisdiv',
546 cls : 'funcprototype',
548 this.returntype + ' ' + nmp,
574 getChildContainer : function(build_call)
578 return this.el.select('.roo-params',true).first();
595 * @class Roo.doc.NavCategory
596 * @extends Roo.bootstrap.Component
597 * Navigation Category class
598 * @cfg {string} title
601 * Represent's an category on the left menu.
602 * - phpdoc @category elements map the pages to the categories
603 * this should be on the left side of the menu, when the
604 * contents are loaded, then it can expand this out, and add links
605 * for each of the methods.
610 * Create a new Navigation Category
611 * @param {Object} config The config object
614 Roo.doc.NavCategory = function(config){
615 Roo.doc.Para.superclass.constructor.call(this, config);
616 Roo.doc.NavCategory.registry[this.name] = this;
618 Roo.doc.NavCategory.registry = {};
619 Roo.extend(Roo.doc.NavCategory, Roo.bootstrap.Component, {
623 getAutoCreate : function(){
625 //?? this is the synopsis type....
627 // this is not very fancy...
635 cls: 'roo-nav-category',
636 href : '#' + this.name,
640 cls : 'container roo-child-ctr'
647 getChildContainer : function()
649 return this.el.select('.roo-child-ctr',true).first();