From 04ecef7e25af1917bef5dcf21cab627be05d2801 Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Mon, 7 Nov 2016 17:41:34 +0000 Subject: [PATCH 1/3] update readme for contrib_nbextensions_help_item to add link to readthedocs --- .../nbextensions/contrib_nbextensions_help_item/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/contrib_nbextensions_help_item/README.md b/src/jupyter_contrib_nbextensions/nbextensions/contrib_nbextensions_help_item/README.md index c9afd877e..d4ce0987a 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/contrib_nbextensions_help_item/README.md +++ b/src/jupyter_contrib_nbextensions/nbextensions/contrib_nbextensions_help_item/README.md @@ -1,4 +1,6 @@ Help menu entry =============== -The contrib_nbextensions_help_item is a tiny extension that just adds an item in the notebook's help menu, pointing to the jupyter_contrib_nbextensions at readthedocs. +The `contrib_nbextensions_help_item` is a tiny nbextension that just adds an +item to the notebook's help menu, pointing to the docs at readthedocs: +[jupyter_contrib_nbextensions.readthedocs.io](https://jupyter_contrib_nbextensions.readthedocs.io) From 9faee4ca7e28acb2201a1f7102076f3d92081fc1 Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Mon, 7 Nov 2016 17:42:18 +0000 Subject: [PATCH 2/3] add icon to datestamper readme --- .../nbextensions/datestamper/readme.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/datestamper/readme.md b/src/jupyter_contrib_nbextensions/nbextensions/datestamper/readme.md index 521b7c2f7..494755112 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/datestamper/readme.md +++ b/src/jupyter_contrib_nbextensions/nbextensions/datestamper/readme.md @@ -1,4 +1,6 @@ Datestamper =========== -Adds a toolbar button which pastes the current time & date into the current cell. +Adds a toolbar button which pastes the current time & date into the current cell: + +![](icon.png) From bd3c9d55cf4784dec698c06e015dbf6037cc285f Mon Sep 17 00:00:00 2001 From: Josh Barnes Date: Mon, 7 Nov 2016 17:48:05 +0000 Subject: [PATCH 3/3] minor updates to codefolding readme mainly nbconvert_support --- .../nbextensions/codefolding/readme.md | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/jupyter_contrib_nbextensions/nbextensions/codefolding/readme.md b/src/jupyter_contrib_nbextensions/nbextensions/codefolding/readme.md index 21126732e..6594a5ef8 100644 --- a/src/jupyter_contrib_nbextensions/nbextensions/codefolding/readme.md +++ b/src/jupyter_contrib_nbextensions/nbextensions/codefolding/readme.md @@ -1,60 +1,79 @@ Codefolding =========== + This extension adds codefolding functionality from CodeMirror to a codecell. After clicking on the gutter (left margin of codecell) or typing `Alt+F`, the code gets folded. See the examples below. The folding status is saved in the cell metadata of the notebook, so reloading of a notebook will restore the folding view. Supported modes --------------- + Three different folding modes are supported: + ### Indent Folding + Python-style code folding, detetects indented code. ![Unfolded](codefolding_indent_unfolded.png) The unfolded code above can be folded like this: + ![](codefolding_indent_folded_1.png) or this: + ![](codefolding_indent_folded_2.png) ### Bracket Folding + Other languages like Javascript use brackets to designate code blocks. Codefolding is supported for Javascript in using the `%%javascript` magic in a codecell. + ### Firstline Comment Folding + Allows collapsing of Python code cells to a single comment line. This is useful for long codecells. The algorithm simply looks for a comment in the first line and allows folding in the rest of the cell. + ![](codefolding_firstline_unfolded.png) The code above can be folded like this: + ![](codefolding_firstline_folded.png) ### Magics Folding + If you specify a magic in the first line of a cell, it can be folded, too. + ![](magic-unfolded.png) Folded: + ![](magic-folded.png) Internals --------- + When saving a notebook, the folding information is saved in the metadata of each codecell. The number of the folding start line (beginning with 0) is stored in an array: ```javascript cell.metadata.code_folding = [ 3, 20, 33 ] ``` + When reloading the notebook, the folding status is restored. + Exporting --------- + To export a notebook containing folded cells, you will need to apply a custom preprocessor for nbconvert. -The preprocessor is located in `nbconvert_support/pre_codefolding.py`. +The preprocessor is located in `jupyter_contrib_nbextensions/nbconvert_support/pre_codefolding.py`. The preprocessor is installed when you install the jupyter_contrib_nbextensions package. To activate the preprocessor manually, add the following lines to `jupyter_nbconvert_config.py`: -```javascript -Exporter.preprocessors ='pre_codefolding.CodeFoldingPreprocessor' + +```python +Exporter.preprocessors += ['jupyter_contrib_nbextensions.nbconvert_support.CodeFoldingPreprocessor'] ```