Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
add function to install notebook extensions, switch command line from…
Browse files Browse the repository at this point in the history
… ipython to jupyter, update documentation

improve function to run notebooks offline
  • Loading branch information
sdpython committed Aug 18, 2015
1 parent 4cfab67 commit 5ea6b92
Show file tree
Hide file tree
Showing 14 changed files with 1,185 additions and 27 deletions.
7 changes: 6 additions & 1 deletion README.rst
Expand Up @@ -75,7 +75,12 @@ Versions, Changes
* **1.3 - 2015/??/??**
* **add:** add function check_readme_syntax to check the syntax of file readme.rst
(pipy uses an earlier version of docutils)
* **fix:** fix a bug in function compare_module_version
* **fix:** fix a bug in function *compare_module_version*
* **add:** new function find_notebook_kernel and get_notebook_kernel to find installed kernels on a computer
* **change:** class NotebookRunner now allows to specify a kernel name and to add extra parameters on the command line,
this change was propagated to function find_notebook_kernel, get_notebook_kernel
* **change:** update script generated by the module to start using jupyter short cuts instead of ipython
* **add:** function to install notebook extension and to load them (see notebook section)

* **1.2.781 - 2015/08/15**
* **change:** parameter prog was added to class MagicCommandParser
Expand Down
209 changes: 209 additions & 0 deletions _doc/notebooks/javascript_extension.ipynb
@@ -0,0 +1,209 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Javascript extension for a notebook"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"run_control": {
"marked": false
}
},
"outputs": [],
"source": [
"from pyquickhelper.ipythonhelper import load_extension, install_notebook_extension, get_installed_notebook_extension"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We check the list of installed extensions (from [IPython-notebook-extensions](https://github.com/ipython-contrib/IPython-notebook-extensions/wiki)):"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"['IPython-notebook-extensions-master/config/main',\n",
" 'IPython-notebook-extensions-master/publishing/nbviewer_theme/main',\n",
" 'IPython-notebook-extensions-master/publishing/printview/main',\n",
" 'IPython-notebook-extensions-master/slidemode/main',\n",
" 'IPython-notebook-extensions-master/styling/css_selector/main',\n",
" 'IPython-notebook-extensions-master/styling/zenmode/main',\n",
" 'IPython-notebook-extensions-master/testing/hierarchical_collapse/main',\n",
" 'IPython-notebook-extensions-master/testing/swc/main',\n",
" 'IPython-notebook-extensions-master/usability/chrome-clipboard/main',\n",
" 'IPython-notebook-extensions-master/usability/codefolding/main',\n",
" 'IPython-notebook-extensions-master/usability/dragdrop/main',\n",
" 'IPython-notebook-extensions-master/usability/exercise/main',\n",
" 'IPython-notebook-extensions-master/usability/hide_input/main',\n",
" 'IPython-notebook-extensions-master/usability/init_cell/main',\n",
" 'IPython-notebook-extensions-master/usability/limit_output/main',\n",
" 'IPython-notebook-extensions-master/usability/navigation-hotkeys/main',\n",
" 'IPython-notebook-extensions-master/usability/python-markdown/main',\n",
" 'IPython-notebook-extensions-master/usability/rubberband/main',\n",
" 'IPython-notebook-extensions-master/usability/runtools/main',\n",
" 'IPython-notebook-extensions-master/usability/search-replace/main',\n",
" 'IPython-notebook-extensions-master/usability/skip-traceback/main']"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get_installed_notebook_extension()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If the list is empty, we install them:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"code_folding": [],
"collapsed": false,
"run_control": {
"marked": false
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"downloading https://github.com/ipython-contrib/IPython-notebook-extensions/archive/master.zip to C:\\Users\\auser\\AppData\\Local\\Temp\\tmpt0c6mp8q\\master.zip\n",
"extracting C:\\Users\\auser\\AppData\\Local\\Temp\\tmpt0c6mp8q\\master.zip to C:\\ProgramData\\jupyter\\nbextensions\n"
]
}
],
"source": [
"install_notebook_extension()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And then, we load one of them:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"code_folding": [],
"collapsed": false,
"input_collapsed": false
},
"outputs": [
{
"data": {
"application/javascript": [
"IPython.utils.load_extensions('IPython-notebook-extensions-master/usability/search-replace/main')"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%javascript\n",
"IPython.utils.load_extensions('IPython-notebook-extensions-master/usability/search-replace/main')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Or if you prefer with pyquickhelper:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"code_folding": [
0
],
"collapsed": false,
"input_collapsed": false,
"run_control": {
"marked": true
}
},
"outputs": [
{
"data": {
"application/javascript": [
"IPython.utils.load_extensions('IPython-notebook-extensions-master/usability/hide_input/main')"
],
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"load_extension('IPython-notebook-extensions-master/usability/hide_input/main')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"input_collapsed": false
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

0 comments on commit 5ea6b92

Please sign in to comment.