Skip to content

Server guidelines for example code for ease in converting to notebooks

Bill Reed edited this page Oct 3, 2016 · 1 revision

The tool located at tools/js2Notebook will generate notebooks from the javascript examples. For an example to be cleanly converted into a notebook, the following guidelines should be followed:

  • 2 blank lines will indicate the start of a new notebook cell

  • all comments (except copyrights, usage, unit test) are converted to markdown cells.

  • if there is the unit test check , it must be exactly as follows

    if (typeof sparkContext === 'undefined') { . . }

  • if there are arguments with default values, they need to be in one line in the form:

    var parmValue = ((typeof args !== "undefined") && (args.length > 1)) ? args[1] : defaultValue;

  • if there is a 'run' function, it must ** be declared as " function run()" ** all parameters need to be the same name as the caller input parameters

    function run(sc,file); var result = run(sc,file) ** output from from 'run' must go to var named 'result'

    var result = run(sc,file)

Clone this wiki locally