diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 8fc6e3fcf..49132eced 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -52,7 +52,7 @@ from .handlers import (LoginHandler, LogoutHandler, ) from .notebookmanager import NotebookManager -from IPython.config.application import catch_config_error +from IPython.config.application import catch_config_error, boolean_flag from IPython.core.application import BaseIPythonApplication from IPython.core.profiledir import ProfileDir from IPython.lib.kernel import swallow_argv @@ -157,10 +157,15 @@ flags['read-only'] = ( """ ) +# Add notebook manager flags +flags.update(boolean_flag('script', 'NotebookManager.save_script', + 'Auto-save a .py script everytime the .ipynb notebook is saved', + 'Do not auto-save .py scripts for every notebook')) + # the flags that are specific to the frontend # these must be scrubbed before being passed to the kernel, # or it will raise an error on unrecognized flags -notebook_flags = ['no-browser', 'no-mathjax', 'read-only'] +notebook_flags = ['no-browser', 'no-mathjax', 'read-only', 'script', 'no-script'] aliases = dict(ipkernel_aliases) diff --git a/IPython/frontend/html/notebook/notebookmanager.py b/IPython/frontend/html/notebook/notebookmanager.py index f95b7c45a..02295c4aa 100644 --- a/IPython/frontend/html/notebook/notebookmanager.py +++ b/IPython/frontend/html/notebook/notebookmanager.py @@ -27,12 +27,10 @@ from IPython.config.configurable import LoggingConfigurable from IPython.nbformat import current from IPython.utils.traitlets import Unicode, List, Dict, Bool - #----------------------------------------------------------------------------- -# Code +# Classes #----------------------------------------------------------------------------- - class NotebookManager(LoggingConfigurable): notebook_dir = Unicode(os.getcwd(), config=True, help=""" @@ -40,10 +38,12 @@ class NotebookManager(LoggingConfigurable): """) save_script = Bool(False, config=True, - help="""Also save notebooks as a Python script. + help="""Automatically create a Python script when saving the notebook. - For easier use of import/%loadpy across notebooks, a .py - script will be created next to any .ipynb on each save. + For easier use of import, %run and %loadpy across notebooks, a + .py script will be created next to any + .ipynb on each save. This can also be set with the + short `--script` flag. """ )