Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore some functionality of the sphinx directive. #11402

Merged
merged 5 commits into from Oct 18, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Add an option (`ipython_warning_is_error`) to not stop on error.

The behavior pre-6.5 was to keep on going even if unexpected exceptions
or warnings were shown, on 7.x the default is to abort the build.

For compat reasons (and convenience), you can now set back the behavior
to the original one to just log to stderr and move on.
  • Loading branch information...
Carreau committed Oct 16, 2018
commit ac5788009da4123f0fa38c49c4de4e2ff1348e35
@@ -84,6 +84,10 @@
The compiled regular expression to denote the start of IPython input
lines. The default is ``re.compile('In \[(\d+)\]:\s?(.*)\s*')``. You
shouldn't need to change this.
ipython_warning_is_error: [default to True]
Fail the build if something unexpected happen, for example if a block raise
an exception but does not have the `:okexcept:` flag. The exact behavior of
what is considered strict, may change between the sphinx directive version.
ipython_rgxout:
The compiled regular expression to denote the start of IPython output
lines. The default is ``re.compile('Out\[(\d+)\]:\s?(.*)\s*')``. You
@@ -559,7 +563,8 @@ def process_input(self, data, input_prompt, lineno):
sys.stdout.write(s)
sys.stdout.write(processed_output)
sys.stdout.write('<<<' + ('-' * 73) + '\n\n')
raise RuntimeError('Non Expected exception in `{}` line {}'.format(filename, lineno))
if self.warning_is_error:
raise RuntimeError('Non Expected exception in `{}` line {}'.format(filename, lineno))

# output any warning raised during execution to stdout
# unless :okwarning: has been specified.
@@ -574,7 +579,8 @@ def process_input(self, data, input_prompt, lineno):
w.filename, w.lineno, w.line)
sys.stdout.write(s)
sys.stdout.write('<<<' + ('-' * 73) + '\n')
raise RuntimeError('Non Expected warning in `{}` line {}'.format(filename, lineno))
if self.shell.warning_is_error:
raise RuntimeError('Non Expected warning in `{}` line {}'.format(filename, lineno))

self.cout.truncate(0)
return (ret, input_lines, processed_output,
@@ -899,19 +905,20 @@ def get_config_options(self):
# get regex and prompt stuff
rgxin = config.ipython_rgxin
rgxout = config.ipython_rgxout
warning_is_error= config.ipython_warning_is_error
promptin = config.ipython_promptin
promptout = config.ipython_promptout
mplbackend = config.ipython_mplbackend
exec_lines = config.ipython_execlines
hold_count = config.ipython_holdcount

return (savefig_dir, source_dir, rgxin, rgxout,
promptin, promptout, mplbackend, exec_lines, hold_count)
promptin, promptout, mplbackend, exec_lines, hold_count, warning_is_error)

def setup(self):
# Get configuration values.
(savefig_dir, source_dir, rgxin, rgxout, promptin, promptout,
mplbackend, exec_lines, hold_count) = self.get_config_options()
mplbackend, exec_lines, hold_count, warning_is_error) = self.get_config_options()

try:
os.makedirs(savefig_dir)
@@ -951,6 +958,7 @@ def setup(self):
self.shell.savefig_dir = savefig_dir
self.shell.source_dir = source_dir
self.shell.hold_count = hold_count
self.shell.warning_is_error = warning_is_error

# setup bookmark for saving figures directory
self.shell.process_input_line('bookmark ipy_savedir %s'%savefig_dir,
@@ -1028,6 +1036,7 @@ def setup(app):

app.add_directive('ipython', IPythonDirective)
app.add_config_value('ipython_savefig_dir', 'savefig', 'env')
app.add_config_value('ipython_warning_is_error', True, 'env')
app.add_config_value('ipython_rgxin',
re.compile('In \[(\d+)\]:\s?(.*)\s*'), 'env')
app.add_config_value('ipython_rgxout',
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.