diff --git a/IPython/frontend/html/notebook/static/js/cell.js b/IPython/frontend/html/notebook/static/js/cell.js index 32f45df..ebc1122 100644 --- a/IPython/frontend/html/notebook/static/js/cell.js +++ b/IPython/frontend/html/notebook/static/js/cell.js @@ -9,8 +9,10 @@ // Cell //============================================================================ /** - * @module Cell * An extendable module that provide base functionnality to create cell for notebook. + * @module IPython + * @namespace IPython + * @submodule Cell */ var IPython = (function (IPython) { @@ -102,28 +104,50 @@ var IPython = (function (IPython) { this.selected = false; }; - + /** + * should be overritten by subclass + * @method get_text + */ Cell.prototype.get_text = function () { }; - + /** + * should be overritten by subclass + * @method set_text + * @param {string} text + */ Cell.prototype.set_text = function (text) { }; - + /** + * Refresh codemirror instance + * @method refresh + */ Cell.prototype.refresh = function () { this.code_mirror.refresh(); }; + /** + * should be overritten by subclass + * @method edit + **/ Cell.prototype.edit = function () { }; + /** + * should be overritten by subclass + * @method render + **/ Cell.prototype.render = function () { }; - + /** + * should be overritten by subclass + * serialise cell to json. + * @method toJSON + **/ Cell.prototype.toJSON = function () { var data = {}; data.metadata = this.metadata; @@ -131,6 +155,10 @@ var IPython = (function (IPython) { }; + /** + * should be overritten by subclass + * @method fromJSON + **/ Cell.prototype.fromJSON = function (data) { if (data.metadata !== undefined) { this.metadata = data.metadata; @@ -138,11 +166,19 @@ var IPython = (function (IPython) { }; + /** + * can the cell be splitted in 2 cells. + * @method is_splittable + **/ Cell.prototype.is_splittable = function () { return true; }; + /** + * @return {String} - the text before the cursor + * @method get_pre_cursor + **/ Cell.prototype.get_pre_cursor = function () { var cursor = this.code_mirror.getCursor(); var text = this.code_mirror.getRange({line:0,ch:0}, cursor); @@ -151,6 +187,10 @@ var IPython = (function (IPython) { } + /** + * @return {String} - the text after the cursor + * @method get_post_cursor + **/ Cell.prototype.get_post_cursor = function () { var cursor = this.code_mirror.getCursor(); var last_line_num = this.code_mirror.lineCount()-1; @@ -162,9 +202,15 @@ var IPython = (function (IPython) { }; + /** Grow the cell by hand. This is used upon reloading from JSON, when the + * autogrow handler is not called. + * + * could be made static + * + * @param {Dom element} - element + * @method grow + **/ Cell.prototype.grow = function(element) { - // Grow the cell by hand. This is used upon reloading from JSON, when the - // autogrow handler is not called. var dom = element.get(0); var lines_count = 0; // modified split rule from @@ -178,7 +224,10 @@ var IPython = (function (IPython) { } }; - + /** + * Toggle CodeMirror LineNumber + * @method toggle_line_numbers + **/ Cell.prototype.toggle_line_numbers = function () { if (this.code_mirror.getOption('lineNumbers') == false) { this.code_mirror.setOption('lineNumbers', true); @@ -188,11 +237,22 @@ var IPython = (function (IPython) { this.code_mirror.refresh(); }; + /** + * force codemirror highlight mode + * @method force_highlight + * @param {object} - CodeMirror mode + **/ Cell.prototype.force_highlight = function(mode) { this.user_highlight = mode; this.auto_highlight(); }; + /** + * Try to autodetect cell highlight mode, or use selected mode + * @methods _auto_highlight + * @private + * @param {String|object|undefined} - CodeMirror mode | 'auto' + **/ Cell.prototype._auto_highlight = function (modes) { //Here we handle manually selected modes if( this.user_highlight != undefined && this.user_highlight != 'auto' ) diff --git a/IPython/frontend/html/notebook/static/js/config.js b/IPython/frontend/html/notebook/static/js/config.js index ba4b3c3..106ae32 100644 --- a/IPython/frontend/html/notebook/static/js/config.js +++ b/IPython/frontend/html/notebook/static/js/config.js @@ -9,9 +9,45 @@ // Notebook //============================================================================ -var IPython = (function (IPython) { +/** + * @module IPython + * @namespace IPython + **/ +var IPython = (function (IPython) { + /** + * A place where some stuff can be confugured. + * + * @class config + * @static + * + **/ var config = { + /** + * Dictionary of object to autodetect highlight mode for code cell. + * Item of the dictionnary should take the form : + * + * key : {'reg':[list_of_regexp]} + * + * where `key` will be the code mirror mode name + * and `list_of_regexp` should be a list of regext that should match + * the first line of the cell to trigger this mode. + * + * if `key` is prefixed by the `magic_` prefix the codemirror `mode` + * will be applied only at the end of the first line + * + * @attribute cell_magic_highlight + * @example + * This would trigger javascript mode + * from the second line if first line start with `%%javascript` or `%%jsmagic` + * + * cell_magic_highlight['magic_javascript'] = {'reg':[/^%%javascript/,/^%%jsmagic/]} + * @example + * This would trigger javascript mode + * from the second line if first line start with `var` + * + * cell_magic_highlight['javascript'] = {'reg':[/^var/]} + */ cell_magic_highlight : { 'magic_javascript':{'reg':[/^%%javascript/]} ,'magic_perl' :{'reg':[/^%%perl/]} @@ -20,6 +56,11 @@ var IPython = (function (IPython) { ,'magic_shell' :{'reg':[/^%%bash/]} ,'magic_r' :{'reg':[/^%%R/]} }, + + /** + * same as `cell_magic_highlight` but for raw cells + * @attribute raw_cell_highlight + */ raw_cell_highlight : { 'diff' :{'reg':[/^diff/]} } diff --git a/IPython/frontend/html/notebook/static/js/textcell.js b/IPython/frontend/html/notebook/static/js/textcell.js index 3fa43c5..72c47e6 100644 --- a/IPython/frontend/html/notebook/static/js/textcell.js +++ b/IPython/frontend/html/notebook/static/js/textcell.js @@ -11,6 +11,8 @@ /** A module that allow to create different type of Text Cell + @module IPython + @namespace IPython */ var IPython = (function (IPython) {