From b16218a2ab1adcb3d1da35a2efd2fa5ea5879572 Mon Sep 17 00:00:00 2001 From: shiba6v Date: Mon, 15 Jul 2019 00:42:08 +0900 Subject: [PATCH] update --- README.md | 7 +++++++ jupyter-shape-commentator.js | 28 +++++++++++++++++++++------- jupyter-shape-commentator.yaml | 3 ++- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2ba8355..66f5fd1 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,11 @@ ## Installation ``` jupyter nbextension install https://github.com/shiba6v/jupyter-shape-commentator/archive/master.zip --user +``` + + +## Installation for Development +``` +cd /path/to +jupyter nbextension install . --user ``` \ No newline at end of file diff --git a/jupyter-shape-commentator.js b/jupyter-shape-commentator.js index d15d991..6a22901 100644 --- a/jupyter-shape-commentator.js +++ b/jupyter-shape-commentator.js @@ -15,14 +15,28 @@ define([ } function shape_erase(){ - var parent = document.getElementsByClassName("end_space")[0]; - while (parent.firstChild) { - parent.removeChild(parent.firstChild); + // var parent = document.getElementsByClassName("end_space")[0]; + // while (parent.firstChild) { + // parent.removeChild(parent.firstChild); + // } + // var cell = Jupyter.notebook.get_selected_cell(); + // var orig_text = cell.get_text(); + // cell.set_text("%%shape_erase"+"\\n"+orig_text); + // cell.execute(); + var output_callback = function (out_data){ + console.log(out_data); + }; + var callbacks = { + iopub: { + output: output_callback + } } - var cell = Jupyter.notebook.get_selected_cell(); - var orig_text = cell.get_text(); - cell.set_text("%%shape_erase"+"\\n"+orig_text); - cell.execute(); + var options = { + silent: false, + store_history : true, + stop_on_error: false + }; + cell.notebook.kernel.execute(code, callbacks, options); } function load_ipython_extension() { // if (document.getElementById('shape_commentator_button')!=null){ diff --git a/jupyter-shape-commentator.yaml b/jupyter-shape-commentator.yaml index 9ab833a..7957a52 100644 --- a/jupyter-shape-commentator.yaml +++ b/jupyter-shape-commentator.yaml @@ -2,4 +2,5 @@ Type: IPython Notebook Extension Name: Jupyter Shape Commentator Description: You can add shape comments to your code. Link: README.md -Main: jupyter-shape-commentator.js \ No newline at end of file +Main: jupyter-shape-commentator.js +Compatibility: 4.x, 5.x \ No newline at end of file