/**
* @class Roo.doc.Example
- * @extends Roo.bootstrap.Example
+ * @extends Roo.bootstrap.Component
* Example Element class
- * @cfg {String} lang (phpcode|phpcode) section type.
+ * @cfg {String} title short title describing example
+ * @cfg {String} lang (php|txt|sql) code language.
+ * @cfg {String} code example code
+ * @cfg {String} output The expected output from the code
+ * @cfg {String} outputlang php|txt|sql) output language
+ *
*
* @constructor
* Create a new Synopsis
* @param {Object} config The config object
*/
-Roo.mailer.Section = function(config){
- Roo.mailer.Section.superclass.constructor.call(this, config);
+Roo.doc.Example = function(config){
+ Roo.doc.Example.superclass.constructor.call(this, config);
};
-Roo.extend(Roo.mailer.Section, Roo.bootstrap.Component, {
+Roo.extend(Roo.doc.Example, Roo.bootstrap.Component, {
+ title : '',
+ lang: 'php',
+ code : '',
+ output : '',
+ outputlang : 'txt',
- stype: '',
-
getAutoCreate : function(){
+ // no colour highlighting in here....
+
+ var code = hljs ? hljs.highlight(this.lang,this.code).value :
+ String.format('{0}',this.code).replace(/\n/g, '<br/>');
+
+ Roo.log("code=" + code);
var cfg ={
-
- cls : 'refsection',
- // id... ?
+ cls : 'panel panel-info',
cn : [
{
- tag: 'h1',
- cls : 'title',
- html : this.stype.charAt(0).toUpperCase() + this.stype.slice(1) //ucfirst
+ cls : 'panel-heading',
+ html : this.title
+ },
+ {
+ cls : 'panel-body',
+ cn : [
+ {
+ tag: 'pre',
+ cls : 'lang-' + this.lang,
+ html : code
+ }
+ ]
}
]
- }
- if (this.stype == 'parameter') {
+ };
+
+ if (this.output) {
+
+ var out = hljs ? hljs.highlight(this.outputlang,this.output).value :
+ String.format('{0}',this.output).replace(/\n/g, '<br/>');
+ cfg.cn.push(
+
+ {
+ cls : 'panel-footer',
+ cn : {
+ tag: 'pre',
+ html : out
+ }
+ }
- // db package uses variable list here... - it results in dd/dl but the layout is messed up..
- cfg.cn.push({
- tag: 'ul',
- cls: 'itemizedlist roo-params'
- })
+
+ );
}
+
return cfg;
- },
+ }