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 || syn.returntype.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',
478 'throws' : 'Throws Exception'
486 * @class Roo.doc.Synopsis
487 * @extends Roo.bootstrap.Component
488 * Synopsis Element class
489 * @cfg {String} returntype return value
490 * @cfg {String} returndesc description of return value. (used in the return section if set..)
491 * @cfg {String} name title really..
492 * @cfg {String} stype (function|constant)
493 * @cfg {String} memberof class name
494 * @cfg {bool} is_static is a static member
495 * @cfg {bool} is_constructor is a static member
498 * Create a new Synopsis
499 * @param {Object} config The config object
502 Roo.doc.Synopsis = function(config){
503 Roo.doc.Synopsis.superclass.constructor.call(this, config);
506 Roo.extend(Roo.doc.Synopsis, Roo.bootstrap.Component, {
514 is_constructor : false,
516 getAutoCreate : function(){
518 var syn = this.items[0]; // hopefully...
522 var nmp = (this.is_static ? '' : '$') +
524 (this.is_static ? '::' : '->');
527 // this should probably do the params....?? then we need to disable the rendering..
529 if (this.is_constructor) {
538 cls : 'refsynopsisdiv',
547 cls : 'funcprototype',
549 this.returntype + ' ' + nmp,
575 getChildContainer : function(build_call)
579 return this.el.select('.roo-params',true).first();
596 * @class Roo.doc.NavCategory
597 * @extends Roo.bootstrap.Component
598 * Navigation Category class
599 * @cfg {string} title
602 * Represent's an category on the left menu.
603 * - phpdoc @category elements map the pages to the categories
604 * this should be on the left side of the menu, when the
605 * contents are loaded, then it can expand this out, and add links
606 * for each of the methods.
611 * Create a new Navigation Category
612 * @param {Object} config The config object
615 Roo.doc.NavCategory = function(config){
616 Roo.doc.Para.superclass.constructor.call(this, config);
617 Roo.doc.NavCategory.registry[this.name] = this;
619 Roo.doc.NavCategory.registry = {};
620 Roo.extend(Roo.doc.NavCategory, Roo.bootstrap.Component, {
624 getAutoCreate : function(){
626 //?? this is the synopsis type....
628 // this is not very fancy...
636 cls: 'roo-nav-category',
637 href : '#' + this.name,
641 cls : 'container roo-child-ctr'
648 getChildContainer : function()
650 return this.el.select('.roo-child-ctr',true).first();