diff --git a/IPython/frontend/html/notebook/notebookapp.py b/IPython/frontend/html/notebook/notebookapp.py index 8fc6e3f..2c27273 100644 --- a/IPython/frontend/html/notebook/notebookapp.py +++ b/IPython/frontend/html/notebook/notebookapp.py @@ -50,7 +50,7 @@ from .handlers import (LoginHandler, LogoutHandler, MainKernelHandler, KernelHandler, KernelActionHandler, IOPubHandler, ShellHandler, NotebookRootHandler, NotebookHandler, RSTHandler ) -from .notebookmanager import NotebookManager +from .notebookmanager import NotebookManager, manager_flags from IPython.config.application import catch_config_error from IPython.core.application import BaseIPythonApplication @@ -157,10 +157,12 @@ flags['read-only'] = ( """ ) +flags.update(manager_flags) + # 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'] aliases = dict(ipkernel_aliases) diff --git a/IPython/frontend/html/notebook/notebookmanager.py b/IPython/frontend/html/notebook/notebookmanager.py index f95b7c4..76b9e9c 100644 --- a/IPython/frontend/html/notebook/notebookmanager.py +++ b/IPython/frontend/html/notebook/notebookmanager.py @@ -23,15 +23,22 @@ import glob from tornado import web +from IPython.config.application import boolean_flag from IPython.config.configurable import LoggingConfigurable from IPython.nbformat import current from IPython.utils.traitlets import Unicode, List, Dict, Bool - #----------------------------------------------------------------------------- -# Code +# Aliases and Flags #----------------------------------------------------------------------------- +manager_flags =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') + +#----------------------------------------------------------------------------- +# Classes +#----------------------------------------------------------------------------- class NotebookManager(LoggingConfigurable): @@ -40,10 +47,12 @@ class NotebookManager(LoggingConfigurable): """) save_script = Bool(False, config=True, - help="""Also save notebooks as a Python script. + help="""Automaticall 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. """ )