##// END OF EJS Templates
Backport PR #10373 on branch 5.x...
Matthias Bussonnier -
Show More
@@ -1,372 +1,379 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 # encoding: utf-8
2 # encoding: utf-8
3 """
3 """
4 The :class:`~IPython.core.application.Application` object for the command
4 The :class:`~IPython.core.application.Application` object for the command
5 line :command:`ipython` program.
5 line :command:`ipython` program.
6 """
6 """
7
7
8 # Copyright (c) IPython Development Team.
8 # Copyright (c) IPython Development Team.
9 # Distributed under the terms of the Modified BSD License.
9 # Distributed under the terms of the Modified BSD License.
10
10
11 from __future__ import absolute_import
11 from __future__ import absolute_import
12 from __future__ import print_function
12 from __future__ import print_function
13
13
14 import logging
14 import logging
15 import os
15 import os
16 import sys
16 import sys
17 import warnings
17 import warnings
18
18
19 from traitlets.config.loader import Config
19 from traitlets.config.loader import Config
20 from traitlets.config.application import boolean_flag, catch_config_error, Application
20 from traitlets.config.application import boolean_flag, catch_config_error, Application
21 from IPython.core import release
21 from IPython.core import release
22 from IPython.core import usage
22 from IPython.core import usage
23 from IPython.core.completer import IPCompleter
23 from IPython.core.completer import IPCompleter
24 from IPython.core.crashhandler import CrashHandler
24 from IPython.core.crashhandler import CrashHandler
25 from IPython.core.formatters import PlainTextFormatter
25 from IPython.core.formatters import PlainTextFormatter
26 from IPython.core.history import HistoryManager
26 from IPython.core.history import HistoryManager
27 from IPython.core.application import (
27 from IPython.core.application import (
28 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
28 ProfileDir, BaseIPythonApplication, base_flags, base_aliases
29 )
29 )
30 from IPython.core.magics import ScriptMagics
30 from IPython.core.magics import ScriptMagics
31 from IPython.core.shellapp import (
31 from IPython.core.shellapp import (
32 InteractiveShellApp, shell_flags, shell_aliases
32 InteractiveShellApp, shell_flags, shell_aliases
33 )
33 )
34 from IPython.extensions.storemagic import StoreMagics
34 from IPython.extensions.storemagic import StoreMagics
35 from .interactiveshell import TerminalInteractiveShell
35 from .interactiveshell import TerminalInteractiveShell
36 from IPython.paths import get_ipython_dir
36 from IPython.paths import get_ipython_dir
37 from traitlets import (
37 from traitlets import (
38 Bool, List, Dict, default, observe,
38 Bool, List, Dict, default, observe, Type
39 )
39 )
40
40
41 #-----------------------------------------------------------------------------
41 #-----------------------------------------------------------------------------
42 # Globals, utilities and helpers
42 # Globals, utilities and helpers
43 #-----------------------------------------------------------------------------
43 #-----------------------------------------------------------------------------
44
44
45 _examples = """
45 _examples = """
46 ipython --matplotlib # enable matplotlib integration
46 ipython --matplotlib # enable matplotlib integration
47 ipython --matplotlib=qt # enable matplotlib integration with qt4 backend
47 ipython --matplotlib=qt # enable matplotlib integration with qt4 backend
48
48
49 ipython --log-level=DEBUG # set logging to DEBUG
49 ipython --log-level=DEBUG # set logging to DEBUG
50 ipython --profile=foo # start with profile foo
50 ipython --profile=foo # start with profile foo
51
51
52 ipython profile create foo # create profile foo w/ default config files
52 ipython profile create foo # create profile foo w/ default config files
53 ipython help profile # show the help for the profile subcmd
53 ipython help profile # show the help for the profile subcmd
54
54
55 ipython locate # print the path to the IPython directory
55 ipython locate # print the path to the IPython directory
56 ipython locate profile foo # print the path to the directory for profile `foo`
56 ipython locate profile foo # print the path to the directory for profile `foo`
57 """
57 """
58
58
59 #-----------------------------------------------------------------------------
59 #-----------------------------------------------------------------------------
60 # Crash handler for this application
60 # Crash handler for this application
61 #-----------------------------------------------------------------------------
61 #-----------------------------------------------------------------------------
62
62
63 class IPAppCrashHandler(CrashHandler):
63 class IPAppCrashHandler(CrashHandler):
64 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
64 """sys.excepthook for IPython itself, leaves a detailed report on disk."""
65
65
66 def __init__(self, app):
66 def __init__(self, app):
67 contact_name = release.author
67 contact_name = release.author
68 contact_email = release.author_email
68 contact_email = release.author_email
69 bug_tracker = 'https://github.com/ipython/ipython/issues'
69 bug_tracker = 'https://github.com/ipython/ipython/issues'
70 super(IPAppCrashHandler,self).__init__(
70 super(IPAppCrashHandler,self).__init__(
71 app, contact_name, contact_email, bug_tracker
71 app, contact_name, contact_email, bug_tracker
72 )
72 )
73
73
74 def make_report(self,traceback):
74 def make_report(self,traceback):
75 """Return a string containing a crash report."""
75 """Return a string containing a crash report."""
76
76
77 sec_sep = self.section_sep
77 sec_sep = self.section_sep
78 # Start with parent report
78 # Start with parent report
79 report = [super(IPAppCrashHandler, self).make_report(traceback)]
79 report = [super(IPAppCrashHandler, self).make_report(traceback)]
80 # Add interactive-specific info we may have
80 # Add interactive-specific info we may have
81 rpt_add = report.append
81 rpt_add = report.append
82 try:
82 try:
83 rpt_add(sec_sep+"History of session input:")
83 rpt_add(sec_sep+"History of session input:")
84 for line in self.app.shell.user_ns['_ih']:
84 for line in self.app.shell.user_ns['_ih']:
85 rpt_add(line)
85 rpt_add(line)
86 rpt_add('\n*** Last line of input (may not be in above history):\n')
86 rpt_add('\n*** Last line of input (may not be in above history):\n')
87 rpt_add(self.app.shell._last_input_line+'\n')
87 rpt_add(self.app.shell._last_input_line+'\n')
88 except:
88 except:
89 pass
89 pass
90
90
91 return ''.join(report)
91 return ''.join(report)
92
92
93 #-----------------------------------------------------------------------------
93 #-----------------------------------------------------------------------------
94 # Aliases and Flags
94 # Aliases and Flags
95 #-----------------------------------------------------------------------------
95 #-----------------------------------------------------------------------------
96 flags = dict(base_flags)
96 flags = dict(base_flags)
97 flags.update(shell_flags)
97 flags.update(shell_flags)
98 frontend_flags = {}
98 frontend_flags = {}
99 addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
99 addflag = lambda *args: frontend_flags.update(boolean_flag(*args))
100 addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
100 addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax',
101 'Turn on auto editing of files with syntax errors.',
101 'Turn on auto editing of files with syntax errors.',
102 'Turn off auto editing of files with syntax errors.'
102 'Turn off auto editing of files with syntax errors.'
103 )
103 )
104 addflag('simple-prompt', 'TerminalInteractiveShell.simple_prompt',
104 addflag('simple-prompt', 'TerminalInteractiveShell.simple_prompt',
105 "Force simple minimal prompt using `raw_input`",
105 "Force simple minimal prompt using `raw_input`",
106 "Use a rich interactive prompt with prompt_toolkit",
106 "Use a rich interactive prompt with prompt_toolkit",
107 )
107 )
108
108
109 addflag('banner', 'TerminalIPythonApp.display_banner',
109 addflag('banner', 'TerminalIPythonApp.display_banner',
110 "Display a banner upon starting IPython.",
110 "Display a banner upon starting IPython.",
111 "Don't display a banner upon starting IPython."
111 "Don't display a banner upon starting IPython."
112 )
112 )
113 addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
113 addflag('confirm-exit', 'TerminalInteractiveShell.confirm_exit',
114 """Set to confirm when you try to exit IPython with an EOF (Control-D
114 """Set to confirm when you try to exit IPython with an EOF (Control-D
115 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
115 in Unix, Control-Z/Enter in Windows). By typing 'exit' or 'quit',
116 you can force a direct exit without any confirmation.""",
116 you can force a direct exit without any confirmation.""",
117 "Don't prompt the user when exiting."
117 "Don't prompt the user when exiting."
118 )
118 )
119 addflag('term-title', 'TerminalInteractiveShell.term_title',
119 addflag('term-title', 'TerminalInteractiveShell.term_title',
120 "Enable auto setting the terminal title.",
120 "Enable auto setting the terminal title.",
121 "Disable auto setting the terminal title."
121 "Disable auto setting the terminal title."
122 )
122 )
123 classic_config = Config()
123 classic_config = Config()
124 classic_config.InteractiveShell.cache_size = 0
124 classic_config.InteractiveShell.cache_size = 0
125 classic_config.PlainTextFormatter.pprint = False
125 classic_config.PlainTextFormatter.pprint = False
126 classic_config.TerminalInteractiveShell.prompts_class='IPython.terminal.prompts.ClassicPrompts'
126 classic_config.TerminalInteractiveShell.prompts_class='IPython.terminal.prompts.ClassicPrompts'
127 classic_config.InteractiveShell.separate_in = ''
127 classic_config.InteractiveShell.separate_in = ''
128 classic_config.InteractiveShell.separate_out = ''
128 classic_config.InteractiveShell.separate_out = ''
129 classic_config.InteractiveShell.separate_out2 = ''
129 classic_config.InteractiveShell.separate_out2 = ''
130 classic_config.InteractiveShell.colors = 'NoColor'
130 classic_config.InteractiveShell.colors = 'NoColor'
131 classic_config.InteractiveShell.xmode = 'Plain'
131 classic_config.InteractiveShell.xmode = 'Plain'
132
132
133 frontend_flags['classic']=(
133 frontend_flags['classic']=(
134 classic_config,
134 classic_config,
135 "Gives IPython a similar feel to the classic Python prompt."
135 "Gives IPython a similar feel to the classic Python prompt."
136 )
136 )
137 # # log doesn't make so much sense this way anymore
137 # # log doesn't make so much sense this way anymore
138 # paa('--log','-l',
138 # paa('--log','-l',
139 # action='store_true', dest='InteractiveShell.logstart',
139 # action='store_true', dest='InteractiveShell.logstart',
140 # help="Start logging to the default log file (./ipython_log.py).")
140 # help="Start logging to the default log file (./ipython_log.py).")
141 #
141 #
142 # # quick is harder to implement
142 # # quick is harder to implement
143 frontend_flags['quick']=(
143 frontend_flags['quick']=(
144 {'TerminalIPythonApp' : {'quick' : True}},
144 {'TerminalIPythonApp' : {'quick' : True}},
145 "Enable quick startup with no config files."
145 "Enable quick startup with no config files."
146 )
146 )
147
147
148 frontend_flags['i'] = (
148 frontend_flags['i'] = (
149 {'TerminalIPythonApp' : {'force_interact' : True}},
149 {'TerminalIPythonApp' : {'force_interact' : True}},
150 """If running code from the command line, become interactive afterwards.
150 """If running code from the command line, become interactive afterwards.
151 It is often useful to follow this with `--` to treat remaining flags as
151 It is often useful to follow this with `--` to treat remaining flags as
152 script arguments.
152 script arguments.
153 """
153 """
154 )
154 )
155 flags.update(frontend_flags)
155 flags.update(frontend_flags)
156
156
157 aliases = dict(base_aliases)
157 aliases = dict(base_aliases)
158 aliases.update(shell_aliases)
158 aliases.update(shell_aliases)
159
159
160 #-----------------------------------------------------------------------------
160 #-----------------------------------------------------------------------------
161 # Main classes and functions
161 # Main classes and functions
162 #-----------------------------------------------------------------------------
162 #-----------------------------------------------------------------------------
163
163
164
164
165 class LocateIPythonApp(BaseIPythonApplication):
165 class LocateIPythonApp(BaseIPythonApplication):
166 description = """print the path to the IPython dir"""
166 description = """print the path to the IPython dir"""
167 subcommands = Dict(dict(
167 subcommands = Dict(dict(
168 profile=('IPython.core.profileapp.ProfileLocate',
168 profile=('IPython.core.profileapp.ProfileLocate',
169 "print the path to an IPython profile directory",
169 "print the path to an IPython profile directory",
170 ),
170 ),
171 ))
171 ))
172 def start(self):
172 def start(self):
173 if self.subapp is not None:
173 if self.subapp is not None:
174 return self.subapp.start()
174 return self.subapp.start()
175 else:
175 else:
176 print(self.ipython_dir)
176 print(self.ipython_dir)
177
177
178
178
179 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
179 class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):
180 name = u'ipython'
180 name = u'ipython'
181 description = usage.cl_usage
181 description = usage.cl_usage
182 crash_handler_class = IPAppCrashHandler
182 crash_handler_class = IPAppCrashHandler
183 examples = _examples
183 examples = _examples
184
184
185 flags = Dict(flags)
185 flags = Dict(flags)
186 aliases = Dict(aliases)
186 aliases = Dict(aliases)
187 classes = List()
187 classes = List()
188
189 interactive_shell_class = Type(
190 klass=object, # use default_value otherwise which only allow subclasses.
191 default_value=TerminalInteractiveShell,
192 help="Class to use to instantiate the TerminalInteractiveShell object. Useful for custom Frontends"
193 ).tag(config=True)
194
188 @default('classes')
195 @default('classes')
189 def _classes_default(self):
196 def _classes_default(self):
190 """This has to be in a method, for TerminalIPythonApp to be available."""
197 """This has to be in a method, for TerminalIPythonApp to be available."""
191 return [
198 return [
192 InteractiveShellApp, # ShellApp comes before TerminalApp, because
199 InteractiveShellApp, # ShellApp comes before TerminalApp, because
193 self.__class__, # it will also affect subclasses (e.g. QtConsole)
200 self.__class__, # it will also affect subclasses (e.g. QtConsole)
194 TerminalInteractiveShell,
201 TerminalInteractiveShell,
195 HistoryManager,
202 HistoryManager,
196 ProfileDir,
203 ProfileDir,
197 PlainTextFormatter,
204 PlainTextFormatter,
198 IPCompleter,
205 IPCompleter,
199 ScriptMagics,
206 ScriptMagics,
200 StoreMagics,
207 StoreMagics,
201 ]
208 ]
202
209
203 deprecated_subcommands = dict(
210 deprecated_subcommands = dict(
204 qtconsole=('qtconsole.qtconsoleapp.JupyterQtConsoleApp',
211 qtconsole=('qtconsole.qtconsoleapp.JupyterQtConsoleApp',
205 """DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter Qt Console."""
212 """DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter Qt Console."""
206 ),
213 ),
207 notebook=('notebook.notebookapp.NotebookApp',
214 notebook=('notebook.notebookapp.NotebookApp',
208 """DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter HTML Notebook Server."""
215 """DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter HTML Notebook Server."""
209 ),
216 ),
210 console=('jupyter_console.app.ZMQTerminalIPythonApp',
217 console=('jupyter_console.app.ZMQTerminalIPythonApp',
211 """DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter terminal-based Console."""
218 """DEPRECATED, Will be removed in IPython 6.0 : Launch the Jupyter terminal-based Console."""
212 ),
219 ),
213 nbconvert=('nbconvert.nbconvertapp.NbConvertApp',
220 nbconvert=('nbconvert.nbconvertapp.NbConvertApp',
214 "DEPRECATED, Will be removed in IPython 6.0 : Convert notebooks to/from other formats."
221 "DEPRECATED, Will be removed in IPython 6.0 : Convert notebooks to/from other formats."
215 ),
222 ),
216 trust=('nbformat.sign.TrustNotebookApp',
223 trust=('nbformat.sign.TrustNotebookApp',
217 "DEPRECATED, Will be removed in IPython 6.0 : Sign notebooks to trust their potentially unsafe contents at load."
224 "DEPRECATED, Will be removed in IPython 6.0 : Sign notebooks to trust their potentially unsafe contents at load."
218 ),
225 ),
219 kernelspec=('jupyter_client.kernelspecapp.KernelSpecApp',
226 kernelspec=('jupyter_client.kernelspecapp.KernelSpecApp',
220 "DEPRECATED, Will be removed in IPython 6.0 : Manage Jupyter kernel specifications."
227 "DEPRECATED, Will be removed in IPython 6.0 : Manage Jupyter kernel specifications."
221 ),
228 ),
222 )
229 )
223 subcommands = dict(
230 subcommands = dict(
224 profile = ("IPython.core.profileapp.ProfileApp",
231 profile = ("IPython.core.profileapp.ProfileApp",
225 "Create and manage IPython profiles."
232 "Create and manage IPython profiles."
226 ),
233 ),
227 kernel = ("ipykernel.kernelapp.IPKernelApp",
234 kernel = ("ipykernel.kernelapp.IPKernelApp",
228 "Start a kernel without an attached frontend."
235 "Start a kernel without an attached frontend."
229 ),
236 ),
230 locate=('IPython.terminal.ipapp.LocateIPythonApp',
237 locate=('IPython.terminal.ipapp.LocateIPythonApp',
231 LocateIPythonApp.description
238 LocateIPythonApp.description
232 ),
239 ),
233 history=('IPython.core.historyapp.HistoryApp',
240 history=('IPython.core.historyapp.HistoryApp',
234 "Manage the IPython history database."
241 "Manage the IPython history database."
235 ),
242 ),
236 )
243 )
237 deprecated_subcommands['install-nbextension'] = (
244 deprecated_subcommands['install-nbextension'] = (
238 "notebook.nbextensions.InstallNBExtensionApp",
245 "notebook.nbextensions.InstallNBExtensionApp",
239 "DEPRECATED, Will be removed in IPython 6.0 : Install Jupyter notebook extension files"
246 "DEPRECATED, Will be removed in IPython 6.0 : Install Jupyter notebook extension files"
240 )
247 )
241 subcommands.update(deprecated_subcommands)
248 subcommands.update(deprecated_subcommands)
242
249
243 # *do* autocreate requested profile, but don't create the config file.
250 # *do* autocreate requested profile, but don't create the config file.
244 auto_create=Bool(True)
251 auto_create=Bool(True)
245 # configurables
252 # configurables
246 quick = Bool(False,
253 quick = Bool(False,
247 help="""Start IPython quickly by skipping the loading of config files."""
254 help="""Start IPython quickly by skipping the loading of config files."""
248 ).tag(config=True)
255 ).tag(config=True)
249 @observe('quick')
256 @observe('quick')
250 def _quick_changed(self, change):
257 def _quick_changed(self, change):
251 if change['new']:
258 if change['new']:
252 self.load_config_file = lambda *a, **kw: None
259 self.load_config_file = lambda *a, **kw: None
253
260
254 display_banner = Bool(True,
261 display_banner = Bool(True,
255 help="Whether to display a banner upon starting IPython."
262 help="Whether to display a banner upon starting IPython."
256 ).tag(config=True)
263 ).tag(config=True)
257
264
258 # if there is code of files to run from the cmd line, don't interact
265 # if there is code of files to run from the cmd line, don't interact
259 # unless the --i flag (App.force_interact) is true.
266 # unless the --i flag (App.force_interact) is true.
260 force_interact = Bool(False,
267 force_interact = Bool(False,
261 help="""If a command or file is given via the command-line,
268 help="""If a command or file is given via the command-line,
262 e.g. 'ipython foo.py', start an interactive shell after executing the
269 e.g. 'ipython foo.py', start an interactive shell after executing the
263 file or command."""
270 file or command."""
264 ).tag(config=True)
271 ).tag(config=True)
265 @observe('force_interact')
272 @observe('force_interact')
266 def _force_interact_changed(self, change):
273 def _force_interact_changed(self, change):
267 if change['new']:
274 if change['new']:
268 self.interact = True
275 self.interact = True
269
276
270 @observe('file_to_run', 'code_to_run', 'module_to_run')
277 @observe('file_to_run', 'code_to_run', 'module_to_run')
271 def _file_to_run_changed(self, change):
278 def _file_to_run_changed(self, change):
272 new = change['new']
279 new = change['new']
273 if new:
280 if new:
274 self.something_to_run = True
281 self.something_to_run = True
275 if new and not self.force_interact:
282 if new and not self.force_interact:
276 self.interact = False
283 self.interact = False
277
284
278 # internal, not-configurable
285 # internal, not-configurable
279 something_to_run=Bool(False)
286 something_to_run=Bool(False)
280
287
281 def parse_command_line(self, argv=None):
288 def parse_command_line(self, argv=None):
282 """override to allow old '-pylab' flag with deprecation warning"""
289 """override to allow old '-pylab' flag with deprecation warning"""
283
290
284 argv = sys.argv[1:] if argv is None else argv
291 argv = sys.argv[1:] if argv is None else argv
285
292
286 if '-pylab' in argv:
293 if '-pylab' in argv:
287 # deprecated `-pylab` given,
294 # deprecated `-pylab` given,
288 # warn and transform into current syntax
295 # warn and transform into current syntax
289 argv = argv[:] # copy, don't clobber
296 argv = argv[:] # copy, don't clobber
290 idx = argv.index('-pylab')
297 idx = argv.index('-pylab')
291 warnings.warn("`-pylab` flag has been deprecated.\n"
298 warnings.warn("`-pylab` flag has been deprecated.\n"
292 " Use `--matplotlib <backend>` and import pylab manually.")
299 " Use `--matplotlib <backend>` and import pylab manually.")
293 argv[idx] = '--pylab'
300 argv[idx] = '--pylab'
294
301
295 return super(TerminalIPythonApp, self).parse_command_line(argv)
302 return super(TerminalIPythonApp, self).parse_command_line(argv)
296
303
297 @catch_config_error
304 @catch_config_error
298 def initialize(self, argv=None):
305 def initialize(self, argv=None):
299 """Do actions after construct, but before starting the app."""
306 """Do actions after construct, but before starting the app."""
300 super(TerminalIPythonApp, self).initialize(argv)
307 super(TerminalIPythonApp, self).initialize(argv)
301 if self.subapp is not None:
308 if self.subapp is not None:
302 # don't bother initializing further, starting subapp
309 # don't bother initializing further, starting subapp
303 return
310 return
304 # print self.extra_args
311 # print self.extra_args
305 if self.extra_args and not self.something_to_run:
312 if self.extra_args and not self.something_to_run:
306 self.file_to_run = self.extra_args[0]
313 self.file_to_run = self.extra_args[0]
307 self.init_path()
314 self.init_path()
308 # create the shell
315 # create the shell
309 self.init_shell()
316 self.init_shell()
310 # and draw the banner
317 # and draw the banner
311 self.init_banner()
318 self.init_banner()
312 # Now a variety of things that happen after the banner is printed.
319 # Now a variety of things that happen after the banner is printed.
313 self.init_gui_pylab()
320 self.init_gui_pylab()
314 self.init_extensions()
321 self.init_extensions()
315 self.init_code()
322 self.init_code()
316
323
317 def init_shell(self):
324 def init_shell(self):
318 """initialize the InteractiveShell instance"""
325 """initialize the InteractiveShell instance"""
319 # Create an InteractiveShell instance.
326 # Create an InteractiveShell instance.
320 # shell.display_banner should always be False for the terminal
327 # shell.display_banner should always be False for the terminal
321 # based app, because we call shell.show_banner() by hand below
328 # based app, because we call shell.show_banner() by hand below
322 # so the banner shows *before* all extension loading stuff.
329 # so the banner shows *before* all extension loading stuff.
323 self.shell = TerminalInteractiveShell.instance(parent=self,
330 self.shell = self.interactive_shell_class.instance(parent=self,
324 profile_dir=self.profile_dir,
331 profile_dir=self.profile_dir,
325 ipython_dir=self.ipython_dir, user_ns=self.user_ns)
332 ipython_dir=self.ipython_dir, user_ns=self.user_ns)
326 self.shell.configurables.append(self)
333 self.shell.configurables.append(self)
327
334
328 def init_banner(self):
335 def init_banner(self):
329 """optionally display the banner"""
336 """optionally display the banner"""
330 if self.display_banner and self.interact:
337 if self.display_banner and self.interact:
331 self.shell.show_banner()
338 self.shell.show_banner()
332 # Make sure there is a space below the banner.
339 # Make sure there is a space below the banner.
333 if self.log_level <= logging.INFO: print()
340 if self.log_level <= logging.INFO: print()
334
341
335 def _pylab_changed(self, name, old, new):
342 def _pylab_changed(self, name, old, new):
336 """Replace --pylab='inline' with --pylab='auto'"""
343 """Replace --pylab='inline' with --pylab='auto'"""
337 if new == 'inline':
344 if new == 'inline':
338 warnings.warn("'inline' not available as pylab backend, "
345 warnings.warn("'inline' not available as pylab backend, "
339 "using 'auto' instead.")
346 "using 'auto' instead.")
340 self.pylab = 'auto'
347 self.pylab = 'auto'
341
348
342 def start(self):
349 def start(self):
343 if self.subapp is not None:
350 if self.subapp is not None:
344 return self.subapp.start()
351 return self.subapp.start()
345 # perform any prexec steps:
352 # perform any prexec steps:
346 if self.interact:
353 if self.interact:
347 self.log.debug("Starting IPython's mainloop...")
354 self.log.debug("Starting IPython's mainloop...")
348 self.shell.mainloop()
355 self.shell.mainloop()
349 else:
356 else:
350 self.log.debug("IPython not interactive...")
357 self.log.debug("IPython not interactive...")
351
358
352 def load_default_config(ipython_dir=None):
359 def load_default_config(ipython_dir=None):
353 """Load the default config file from the default ipython_dir.
360 """Load the default config file from the default ipython_dir.
354
361
355 This is useful for embedded shells.
362 This is useful for embedded shells.
356 """
363 """
357 if ipython_dir is None:
364 if ipython_dir is None:
358 ipython_dir = get_ipython_dir()
365 ipython_dir = get_ipython_dir()
359
366
360 profile_dir = os.path.join(ipython_dir, 'profile_default')
367 profile_dir = os.path.join(ipython_dir, 'profile_default')
361
368
362 config = Config()
369 config = Config()
363 for cf in Application._load_config_files("ipython_config", path=profile_dir):
370 for cf in Application._load_config_files("ipython_config", path=profile_dir):
364 config.update(cf)
371 config.update(cf)
365
372
366 return config
373 return config
367
374
368 launch_new_instance = TerminalIPythonApp.launch_instance
375 launch_new_instance = TerminalIPythonApp.launch_instance
369
376
370
377
371 if __name__ == '__main__':
378 if __name__ == '__main__':
372 launch_new_instance()
379 launch_new_instance()
@@ -1,20 +1,19 b''
1 =====================
1 =====================
2 Development version
2 Development version
3 =====================
3 =====================
4
4
5 This document describes in-flight development work.
5 This document describes in-flight development work.
6
6
7 .. warning::
7 .. warning::
8
8
9 Please do not edit this file by hand (doing so will likely cause merge
9 Please do not edit this file by hand (doing so will likely cause merge
10 conflicts for other Pull Requests). Instead, create a new file in the
10 conflicts for other Pull Requests). Instead, create a new file in the
11 `docs/source/whatsnew/pr` folder
11 `docs/source/whatsnew/pr` folder
12
12
13
14 .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT.
13 .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT.
15
14
16
15
17 Backwards incompatible changes
16 Backwards incompatible changes
18 ------------------------------
17 ------------------------------
19
18
20 .. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT.
19 .. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT.
@@ -1,284 +1,298 b''
1 ============
1 ============
2 5.x Series
2 5.x Series
3 ============
3 ============
4
4
5 IPython 5.4
6 ===========
7
8 Configurable TerminalInteractiveShell
9 -------------------------------------
10
11 Backported from the 6.x branch as an exceptional new feature. See
12 :ghpull:`10373` and :ghissue:`10364`
13
14 IPython gained a new ``c.TerminalIPythonApp.interactive_shell_class`` option
15 that allow to customize the class used to start the terminal frontend. This
16 should allow user to use custom interfaces, like reviving the former readline
17 interface which is now a separate package not maintained by the core team.
18
5 IPython 5.3
19 IPython 5.3
6 ===========
20 ===========
7
21
8 Released on February 24th, 2017. Remarkable changes and fixes:
22 Released on February 24th, 2017. Remarkable changes and fixes:
9
23
10 * Fix a bug in ``set_next_input`` leading to a crash of terminal IPython.
24 * Fix a bug in ``set_next_input`` leading to a crash of terminal IPython.
11 :ghpull:`10231`, :ghissue:`10296`, :ghissue:`10229`
25 :ghpull:`10231`, :ghissue:`10296`, :ghissue:`10229`
12 * Always wait for editor inputhook for terminal IPython :ghpull:`10239`,
26 * Always wait for editor inputhook for terminal IPython :ghpull:`10239`,
13 :ghpull:`10240`
27 :ghpull:`10240`
14 * Disable ``_ipython_display_`` in terminal :ghpull:`10249`, :ghpull:`10274`
28 * Disable ``_ipython_display_`` in terminal :ghpull:`10249`, :ghpull:`10274`
15 * Update terminal colors to be more visible by default on windows
29 * Update terminal colors to be more visible by default on windows
16 :ghpull:`10260`, :ghpull:`10238`, :ghissue:`10281`
30 :ghpull:`10260`, :ghpull:`10238`, :ghissue:`10281`
17 * Add Ctrl-Z shortcut (suspend) in terminal debugger :ghpull:`10254`,
31 * Add Ctrl-Z shortcut (suspend) in terminal debugger :ghpull:`10254`,
18 :ghissue:`10273`
32 :ghissue:`10273`
19 * Indent on new line by looking at the text before the cursor :ghpull:`10264`,
33 * Indent on new line by looking at the text before the cursor :ghpull:`10264`,
20 :ghpull:`10275`, :ghissue:`9283`
34 :ghpull:`10275`, :ghissue:`9283`
21 * Update QtEventloop integration to fix some matplotlib integration issues
35 * Update QtEventloop integration to fix some matplotlib integration issues
22 :ghpull:`10201`, :ghpull:`10311`, :ghissue:`10201`
36 :ghpull:`10201`, :ghpull:`10311`, :ghissue:`10201`
23 * Respect completions display style in terminal debugger :ghpull:`10305`,
37 * Respect completions display style in terminal debugger :ghpull:`10305`,
24 :ghpull:`10313`
38 :ghpull:`10313`
25 * Add a config option ``TerminalInteractiveShell.extra_open_editor_shortcuts``
39 * Add a config option ``TerminalInteractiveShell.extra_open_editor_shortcuts``
26 to enable extra shortcuts to open the input in an editor. These are :kbd:`v`
40 to enable extra shortcuts to open the input in an editor. These are :kbd:`v`
27 in vi mode, and :kbd:`C-X C-E` in emacs mode (:ghpull:`10330`).
41 in vi mode, and :kbd:`C-X C-E` in emacs mode (:ghpull:`10330`).
28 The :kbd:`F2` shortcut is always enabled.
42 The :kbd:`F2` shortcut is always enabled.
29
43
30 IPython 5.2.2
44 IPython 5.2.2
31 =============
45 =============
32
46
33 * Fix error when starting with ``IPCompleter.limit_to__all__`` configured.
47 * Fix error when starting with ``IPCompleter.limit_to__all__`` configured.
34
48
35 IPython 5.2.1
49 IPython 5.2.1
36 =============
50 =============
37
51
38 * Fix tab completion in the debugger. :ghpull:`10223`
52 * Fix tab completion in the debugger. :ghpull:`10223`
39
53
40 IPython 5.2
54 IPython 5.2
41 ===========
55 ===========
42
56
43 Released on January 29th, 2017. Remarkable changes and fixes:
57 Released on January 29th, 2017. Remarkable changes and fixes:
44
58
45 * restore IPython's debugger to raise on quit. :ghpull:`10009`
59 * restore IPython's debugger to raise on quit. :ghpull:`10009`
46 * The configuration value ``c.TerminalInteractiveShell.highlighting_style`` can
60 * The configuration value ``c.TerminalInteractiveShell.highlighting_style`` can
47 now directly take a class argument for custom color style. :ghpull:`9848`
61 now directly take a class argument for custom color style. :ghpull:`9848`
48 * Correctly handle matplotlib figures dpi :ghpull:`9868`
62 * Correctly handle matplotlib figures dpi :ghpull:`9868`
49 * Deprecate ``-e`` flag for the ``%notebook`` magic that had no effects.
63 * Deprecate ``-e`` flag for the ``%notebook`` magic that had no effects.
50 :ghpull:`9872`
64 :ghpull:`9872`
51 * You can now press F2 while typing at a terminal prompt to edit the contents
65 * You can now press F2 while typing at a terminal prompt to edit the contents
52 in your favourite terminal editor. Set the :envvar:`EDITOR` environment
66 in your favourite terminal editor. Set the :envvar:`EDITOR` environment
53 variable to pick which editor is used. :ghpull:`9929`
67 variable to pick which editor is used. :ghpull:`9929`
54 * sdists will now only be ``.tar.gz`` as per upstream PyPI requirements.
68 * sdists will now only be ``.tar.gz`` as per upstream PyPI requirements.
55 :ghpull:`9925`
69 :ghpull:`9925`
56 * :any:`IPython.core.debugger` have gained a ``set_trace()`` method for
70 * :any:`IPython.core.debugger` have gained a ``set_trace()`` method for
57 convenience. :ghpull:`9947`
71 convenience. :ghpull:`9947`
58 * The 'smart command mode' added to the debugger in 5.0 was removed, as more
72 * The 'smart command mode' added to the debugger in 5.0 was removed, as more
59 people preferred the previous behaviour. Therefore, debugger commands such as
73 people preferred the previous behaviour. Therefore, debugger commands such as
60 ``c`` will act as debugger commands even when ``c`` is defined as a variable.
74 ``c`` will act as debugger commands even when ``c`` is defined as a variable.
61 :ghpull:`10050`
75 :ghpull:`10050`
62 * Fixes OS X event loop issues at startup, :ghpull:`10150`
76 * Fixes OS X event loop issues at startup, :ghpull:`10150`
63 * Deprecate the ``%autoindent`` magic. :ghpull:`10176`
77 * Deprecate the ``%autoindent`` magic. :ghpull:`10176`
64 * Emit a :any:`DeprecationWarning` when setting the deprecated
78 * Emit a :any:`DeprecationWarning` when setting the deprecated
65 ``limit_to_all`` option of the completer. :ghpull:`10198`
79 ``limit_to_all`` option of the completer. :ghpull:`10198`
66 * The :cellmagic:`capture` magic can now capture the result of a cell (from an
80 * The :cellmagic:`capture` magic can now capture the result of a cell (from an
67 expression on the last line), as well as printed and displayed output.
81 expression on the last line), as well as printed and displayed output.
68 :ghpull:`9851`.
82 :ghpull:`9851`.
69
83
70
84
71 Changes of behavior to :any:`InteractiveShellEmbed`.
85 Changes of behavior to :any:`InteractiveShellEmbed`.
72
86
73 :any:`InteractiveShellEmbed` interactive behavior have changed a bit in between
87 :any:`InteractiveShellEmbed` interactive behavior have changed a bit in between
74 5.1 and 5.2. By default ``%kill_embedded`` magic will prevent further invocation
88 5.1 and 5.2. By default ``%kill_embedded`` magic will prevent further invocation
75 of the current ``call location`` instead of preventing further invocation of
89 of the current ``call location`` instead of preventing further invocation of
76 the current instance creation location. For most use case this will not change
90 the current instance creation location. For most use case this will not change
77 much for you, though previous behavior was confusing and less consistent with
91 much for you, though previous behavior was confusing and less consistent with
78 previous IPython versions.
92 previous IPython versions.
79
93
80 You can now deactivate instances by using ``%kill_embedded --instance`` flag,
94 You can now deactivate instances by using ``%kill_embedded --instance`` flag,
81 (or ``-i`` in short). The ``%kill_embedded`` magic also gained a
95 (or ``-i`` in short). The ``%kill_embedded`` magic also gained a
82 ``--yes``/``-y`` option which skip confirmation step, and ``-x``/``--exit``
96 ``--yes``/``-y`` option which skip confirmation step, and ``-x``/``--exit``
83 which also exit the current embedded call without asking for confirmation.
97 which also exit the current embedded call without asking for confirmation.
84
98
85 See :ghpull:`10207`.
99 See :ghpull:`10207`.
86
100
87
101
88
102
89 IPython 5.1
103 IPython 5.1
90 ===========
104 ===========
91
105
92 * Broken ``%timeit`` on Python2 due to the use of ``__qualname__``. :ghpull:`9804`
106 * Broken ``%timeit`` on Python2 due to the use of ``__qualname__``. :ghpull:`9804`
93 * Restore ``%gui qt`` to create and return a ``QApplication`` if necessary. :ghpull:`9789`
107 * Restore ``%gui qt`` to create and return a ``QApplication`` if necessary. :ghpull:`9789`
94 * Don't set terminal title by default. :ghpull:`9801`
108 * Don't set terminal title by default. :ghpull:`9801`
95 * Preserve indentation when inserting newlines with ``Ctrl-O``. :ghpull:`9770`
109 * Preserve indentation when inserting newlines with ``Ctrl-O``. :ghpull:`9770`
96 * Restore completion in debugger. :ghpull:`9785`
110 * Restore completion in debugger. :ghpull:`9785`
97 * Deprecate ``IPython.core.debugger.Tracer()`` in favor of simpler, newer, APIs. :ghpull:`9731`
111 * Deprecate ``IPython.core.debugger.Tracer()`` in favor of simpler, newer, APIs. :ghpull:`9731`
98 * Restore ``NoOpContext`` context manager removed by mistake, and add `DeprecationWarning`. :ghpull:`9765`
112 * Restore ``NoOpContext`` context manager removed by mistake, and add `DeprecationWarning`. :ghpull:`9765`
99 * Add option allowing ``Prompt_toolkit`` to use 24bits colors. :ghpull:`9736`
113 * Add option allowing ``Prompt_toolkit`` to use 24bits colors. :ghpull:`9736`
100 * Fix for closing interactive matplotlib windows on OS X. :ghpull:`9854`
114 * Fix for closing interactive matplotlib windows on OS X. :ghpull:`9854`
101 * An embedded interactive shell instance can be used more than once. :ghpull:`9843`
115 * An embedded interactive shell instance can be used more than once. :ghpull:`9843`
102 * More robust check for whether IPython is in a terminal. :ghpull:`9833`
116 * More robust check for whether IPython is in a terminal. :ghpull:`9833`
103 * Better pretty-printing of dicts on PyPy. :ghpull:`9827`
117 * Better pretty-printing of dicts on PyPy. :ghpull:`9827`
104 * Some coloured output now looks better on dark background command prompts in Windows.
118 * Some coloured output now looks better on dark background command prompts in Windows.
105 :ghpull:`9838`
119 :ghpull:`9838`
106 * Improved tab completion of paths on Windows . :ghpull:`9826`
120 * Improved tab completion of paths on Windows . :ghpull:`9826`
107 * Fix tkinter event loop integration on Python 2 with ``future`` installed. :ghpull:`9824`
121 * Fix tkinter event loop integration on Python 2 with ``future`` installed. :ghpull:`9824`
108 * Restore ``Ctrl-\`` as a shortcut to quit IPython.
122 * Restore ``Ctrl-\`` as a shortcut to quit IPython.
109 * Make ``get_ipython()`` accessible when modules are imported by startup files. :ghpull:`9818`
123 * Make ``get_ipython()`` accessible when modules are imported by startup files. :ghpull:`9818`
110 * Add support for running directories containing a ``__main__.py`` file with the
124 * Add support for running directories containing a ``__main__.py`` file with the
111 ``ipython`` command. :ghpull:`9813`
125 ``ipython`` command. :ghpull:`9813`
112
126
113
127
114 True Color feature
128 True Color feature
115 ------------------
129 ------------------
116
130
117 ``prompt_toolkit`` uses pygments styles for syntax highlighting. By default, the
131 ``prompt_toolkit`` uses pygments styles for syntax highlighting. By default, the
118 colors specified in the style are approximated using a standard 256-color
132 colors specified in the style are approximated using a standard 256-color
119 palette. ``prompt_toolkit`` also supports 24bit, a.k.a. "true", a.k.a. 16-million
133 palette. ``prompt_toolkit`` also supports 24bit, a.k.a. "true", a.k.a. 16-million
120 color escape sequences which enable compatible terminals to display the exact
134 color escape sequences which enable compatible terminals to display the exact
121 colors specified instead of an approximation. This true_color option exposes
135 colors specified instead of an approximation. This true_color option exposes
122 that capability in prompt_toolkit to the IPython shell.
136 that capability in prompt_toolkit to the IPython shell.
123
137
124 Here is a good source for the current state of true color support in various
138 Here is a good source for the current state of true color support in various
125 terminal emulators and software projects: https://gist.github.com/XVilka/8346728
139 terminal emulators and software projects: https://gist.github.com/XVilka/8346728
126
140
127
141
128
142
129 IPython 5.0
143 IPython 5.0
130 ===========
144 ===========
131
145
132 Released July 7, 2016
146 Released July 7, 2016
133
147
134 New terminal interface
148 New terminal interface
135 ----------------------
149 ----------------------
136
150
137 IPython 5 features a major upgrade to the terminal interface, bringing live
151 IPython 5 features a major upgrade to the terminal interface, bringing live
138 syntax highlighting as you type, proper multiline editing and multiline paste,
152 syntax highlighting as you type, proper multiline editing and multiline paste,
139 and tab completions that don't clutter up your history.
153 and tab completions that don't clutter up your history.
140
154
141 .. image:: ../_images/ptshell_features.png
155 .. image:: ../_images/ptshell_features.png
142 :alt: New terminal interface features
156 :alt: New terminal interface features
143 :align: center
157 :align: center
144 :target: ../_images/ptshell_features.png
158 :target: ../_images/ptshell_features.png
145
159
146 These features are provided by the Python library `prompt_toolkit
160 These features are provided by the Python library `prompt_toolkit
147 <http://python-prompt-toolkit.readthedocs.io/en/stable/>`__, which replaces
161 <http://python-prompt-toolkit.readthedocs.io/en/stable/>`__, which replaces
148 ``readline`` throughout our terminal interface.
162 ``readline`` throughout our terminal interface.
149
163
150 Relying on this pure-Python, cross platform module also makes it simpler to
164 Relying on this pure-Python, cross platform module also makes it simpler to
151 install IPython. We have removed dependencies on ``pyreadline`` for Windows and
165 install IPython. We have removed dependencies on ``pyreadline`` for Windows and
152 ``gnureadline`` for Mac.
166 ``gnureadline`` for Mac.
153
167
154 Backwards incompatible changes
168 Backwards incompatible changes
155 ------------------------------
169 ------------------------------
156
170
157 - The ``%install_ext`` magic function, deprecated since 4.0, has now been deleted.
171 - The ``%install_ext`` magic function, deprecated since 4.0, has now been deleted.
158 You can distribute and install extensions as packages on PyPI.
172 You can distribute and install extensions as packages on PyPI.
159 - Callbacks registered while an event is being handled will now only be called
173 - Callbacks registered while an event is being handled will now only be called
160 for subsequent events; previously they could be called for the current event.
174 for subsequent events; previously they could be called for the current event.
161 Similarly, callbacks removed while handling an event *will* always get that
175 Similarly, callbacks removed while handling an event *will* always get that
162 event. See :ghissue:`9447` and :ghpull:`9453`.
176 event. See :ghissue:`9447` and :ghpull:`9453`.
163 - Integration with pydb has been removed since pydb development has been stopped
177 - Integration with pydb has been removed since pydb development has been stopped
164 since 2012, and pydb is not installable from PyPI.
178 since 2012, and pydb is not installable from PyPI.
165 - The ``autoedit_syntax`` option has apparently been broken for many years.
179 - The ``autoedit_syntax`` option has apparently been broken for many years.
166 It has been removed.
180 It has been removed.
167
181
168 New terminal interface
182 New terminal interface
169 ~~~~~~~~~~~~~~~~~~~~~~
183 ~~~~~~~~~~~~~~~~~~~~~~
170
184
171 The overhaul of the terminal interface will probably cause a range of minor
185 The overhaul of the terminal interface will probably cause a range of minor
172 issues for existing users.
186 issues for existing users.
173 This is inevitable for such a significant change, and we've done our best to
187 This is inevitable for such a significant change, and we've done our best to
174 minimise these issues.
188 minimise these issues.
175 Some changes that we're aware of, with suggestions on how to handle them:
189 Some changes that we're aware of, with suggestions on how to handle them:
176
190
177 IPython no longer uses readline configuration (``~/.inputrc``). We hope that
191 IPython no longer uses readline configuration (``~/.inputrc``). We hope that
178 the functionality you want (e.g. vi input mode) will be available by configuring
192 the functionality you want (e.g. vi input mode) will be available by configuring
179 IPython directly (see :doc:`/config/options/terminal`).
193 IPython directly (see :doc:`/config/options/terminal`).
180 If something's missing, please file an issue.
194 If something's missing, please file an issue.
181
195
182 The ``PromptManager`` class has been removed, and the prompt machinery simplified.
196 The ``PromptManager`` class has been removed, and the prompt machinery simplified.
183 See :ref:`custom_prompts` to customise prompts with the new machinery.
197 See :ref:`custom_prompts` to customise prompts with the new machinery.
184
198
185 :mod:`IPython.core.debugger` now provides a plainer interface.
199 :mod:`IPython.core.debugger` now provides a plainer interface.
186 :mod:`IPython.terminal.debugger` contains the terminal debugger using
200 :mod:`IPython.terminal.debugger` contains the terminal debugger using
187 prompt_toolkit.
201 prompt_toolkit.
188
202
189 There are new options to configure the colours used in syntax highlighting.
203 There are new options to configure the colours used in syntax highlighting.
190 We have tried to integrate them with our classic ``--colors`` option and
204 We have tried to integrate them with our classic ``--colors`` option and
191 ``%colors`` magic, but there's a mismatch in possibilities, so some configurations
205 ``%colors`` magic, but there's a mismatch in possibilities, so some configurations
192 may produce unexpected results. See :ref:`termcolour` for more information.
206 may produce unexpected results. See :ref:`termcolour` for more information.
193
207
194 The new interface is not compatible with Emacs 'inferior-shell' feature. To
208 The new interface is not compatible with Emacs 'inferior-shell' feature. To
195 continue using this, add the ``--simple-prompt`` flag to the command Emacs
209 continue using this, add the ``--simple-prompt`` flag to the command Emacs
196 runs. This flag disables most IPython features, relying on Emacs to provide
210 runs. This flag disables most IPython features, relying on Emacs to provide
197 things like tab completion.
211 things like tab completion.
198
212
199 Provisional Changes
213 Provisional Changes
200 -------------------
214 -------------------
201
215
202 Provisional changes are experimental functionality that may, or may not, make
216 Provisional changes are experimental functionality that may, or may not, make
203 it into a future version of IPython, and which API may change without warnings.
217 it into a future version of IPython, and which API may change without warnings.
204 Activating these features and using these API are at your own risk, and may have
218 Activating these features and using these API are at your own risk, and may have
205 security implication for your system, especially if used with the Jupyter notebook,
219 security implication for your system, especially if used with the Jupyter notebook,
206
220
207 When running via the Jupyter notebook interfaces, or other compatible client,
221 When running via the Jupyter notebook interfaces, or other compatible client,
208 you can enable rich documentation experimental functionality:
222 you can enable rich documentation experimental functionality:
209
223
210 When the ``docrepr`` package is installed setting the boolean flag
224 When the ``docrepr`` package is installed setting the boolean flag
211 ``InteractiveShell.sphinxify_docstring`` to ``True``, will process the various
225 ``InteractiveShell.sphinxify_docstring`` to ``True``, will process the various
212 object through sphinx before displaying them (see the ``docrepr`` package
226 object through sphinx before displaying them (see the ``docrepr`` package
213 documentation for more information.
227 documentation for more information.
214
228
215 You need to also enable the IPython pager display rich HTML representation
229 You need to also enable the IPython pager display rich HTML representation
216 using the ``InteractiveShell.enable_html_pager`` boolean configuration option.
230 using the ``InteractiveShell.enable_html_pager`` boolean configuration option.
217 As usual you can set these configuration options globally in your configuration
231 As usual you can set these configuration options globally in your configuration
218 files, alternatively you can turn them on dynamically using the following
232 files, alternatively you can turn them on dynamically using the following
219 snippet:
233 snippet:
220
234
221 .. code-block:: python
235 .. code-block:: python
222
236
223 ip = get_ipython()
237 ip = get_ipython()
224 ip.sphinxify_docstring = True
238 ip.sphinxify_docstring = True
225 ip.enable_html_pager = True
239 ip.enable_html_pager = True
226
240
227
241
228 You can test the effect of various combinations of the above configuration in
242 You can test the effect of various combinations of the above configuration in
229 the Jupyter notebook, with things example like :
243 the Jupyter notebook, with things example like :
230
244
231 .. code-block:: ipython
245 .. code-block:: ipython
232
246
233 import numpy as np
247 import numpy as np
234 np.histogram?
248 np.histogram?
235
249
236
250
237 This is part of an effort to make Documentation in Python richer and provide in
251 This is part of an effort to make Documentation in Python richer and provide in
238 the long term if possible dynamic examples that can contain math, images,
252 the long term if possible dynamic examples that can contain math, images,
239 widgets... As stated above this is nightly experimental feature with a lot of
253 widgets... As stated above this is nightly experimental feature with a lot of
240 (fun) problem to solve. We would be happy to get your feedback and expertise on
254 (fun) problem to solve. We would be happy to get your feedback and expertise on
241 it.
255 it.
242
256
243
257
244
258
245 Deprecated Features
259 Deprecated Features
246 -------------------
260 -------------------
247
261
248 Some deprecated features are listed in this section. Don't forget to enable
262 Some deprecated features are listed in this section. Don't forget to enable
249 ``DeprecationWarning`` as an error if you are using IPython in a Continuous
263 ``DeprecationWarning`` as an error if you are using IPython in a Continuous
250 Integration setup or in your testing in general:
264 Integration setup or in your testing in general:
251
265
252 .. code-block:: python
266 .. code-block:: python
253
267
254 import warnings
268 import warnings
255 warnings.filterwarnings('error', '.*', DeprecationWarning, module='yourmodule.*')
269 warnings.filterwarnings('error', '.*', DeprecationWarning, module='yourmodule.*')
256
270
257
271
258 - ``hooks.fix_error_editor`` seems unused and is pending deprecation.
272 - ``hooks.fix_error_editor`` seems unused and is pending deprecation.
259 - `IPython/core/excolors.py:ExceptionColors` is deprecated.
273 - `IPython/core/excolors.py:ExceptionColors` is deprecated.
260 - `IPython.core.InteractiveShell:write()` is deprecated; use `sys.stdout` instead.
274 - `IPython.core.InteractiveShell:write()` is deprecated; use `sys.stdout` instead.
261 - `IPython.core.InteractiveShell:write_err()` is deprecated; use `sys.stderr` instead.
275 - `IPython.core.InteractiveShell:write_err()` is deprecated; use `sys.stderr` instead.
262 - The `formatter` keyword argument to `Inspector.info` in `IPython.core.oinspec` has no effect.
276 - The `formatter` keyword argument to `Inspector.info` in `IPython.core.oinspec` has no effect.
263 - The `global_ns` keyword argument of IPython Embed was deprecated, and has no effect. Use `module` keyword argument instead.
277 - The `global_ns` keyword argument of IPython Embed was deprecated, and has no effect. Use `module` keyword argument instead.
264
278
265
279
266 Known Issues:
280 Known Issues:
267 -------------
281 -------------
268
282
269 - ``<Esc>`` Key does not dismiss the completer and does not clear the current
283 - ``<Esc>`` Key does not dismiss the completer and does not clear the current
270 buffer. This is an on purpose modification due to current technical
284 buffer. This is an on purpose modification due to current technical
271 limitation. Cf :ghpull:`9572`. Escape the control character which is used
285 limitation. Cf :ghpull:`9572`. Escape the control character which is used
272 for other shortcut, and there is no practical way to distinguish. Use Ctr-G
286 for other shortcut, and there is no practical way to distinguish. Use Ctr-G
273 or Ctrl-C as an alternative.
287 or Ctrl-C as an alternative.
274
288
275 - Cannot use ``Shift-Enter`` and ``Ctrl-Enter`` to submit code in terminal. cf
289 - Cannot use ``Shift-Enter`` and ``Ctrl-Enter`` to submit code in terminal. cf
276 :ghissue:`9587` and :ghissue:`9401`. In terminal there is no practical way to
290 :ghissue:`9587` and :ghissue:`9401`. In terminal there is no practical way to
277 distinguish these key sequences from a normal new line return.
291 distinguish these key sequences from a normal new line return.
278
292
279 - ``PageUp`` and ``pageDown`` do not move through completion menu.
293 - ``PageUp`` and ``pageDown`` do not move through completion menu.
280
294
281 - Color styles might not adapt to terminal emulator themes. This will need new
295 - Color styles might not adapt to terminal emulator themes. This will need new
282 version of Pygments to be released, and can be mitigated with custom themes.
296 version of Pygments to be released, and can be mitigated with custom themes.
283
297
284
298
General Comments 0
You need to be logged in to leave comments. Login now