##// END OF EJS Templates
Add an option (`ipython_warning_is_error`) to not stop on error....
Matthias Bussonnier -
Show More
@@ -84,6 +84,10 b' ipython_rgxin:'
84 84 The compiled regular expression to denote the start of IPython input
85 85 lines. The default is ``re.compile('In \[(\d+)\]:\s?(.*)\s*')``. You
86 86 shouldn't need to change this.
87 ipython_warning_is_error: [default to True]
88 Fail the build if something unexpected happen, for example if a block raise
89 an exception but does not have the `:okexcept:` flag. The exact behavior of
90 what is considered strict, may change between the sphinx directive version.
87 91 ipython_rgxout:
88 92 The compiled regular expression to denote the start of IPython output
89 93 lines. The default is ``re.compile('Out\[(\d+)\]:\s?(.*)\s*')``. You
@@ -559,7 +563,8 b' class EmbeddedSphinxShell(object):'
559 563 sys.stdout.write(s)
560 564 sys.stdout.write(processed_output)
561 565 sys.stdout.write('<<<' + ('-' * 73) + '\n\n')
562 raise RuntimeError('Non Expected exception in `{}` line {}'.format(filename, lineno))
566 if self.warning_is_error:
567 raise RuntimeError('Non Expected exception in `{}` line {}'.format(filename, lineno))
563 568
564 569 # output any warning raised during execution to stdout
565 570 # unless :okwarning: has been specified.
@@ -574,7 +579,8 b' class EmbeddedSphinxShell(object):'
574 579 w.filename, w.lineno, w.line)
575 580 sys.stdout.write(s)
576 581 sys.stdout.write('<<<' + ('-' * 73) + '\n')
577 raise RuntimeError('Non Expected warning in `{}` line {}'.format(filename, lineno))
582 if self.shell.warning_is_error:
583 raise RuntimeError('Non Expected warning in `{}` line {}'.format(filename, lineno))
578 584
579 585 self.cout.truncate(0)
580 586 return (ret, input_lines, processed_output,
@@ -899,6 +905,7 b' class IPythonDirective(Directive):'
899 905 # get regex and prompt stuff
900 906 rgxin = config.ipython_rgxin
901 907 rgxout = config.ipython_rgxout
908 warning_is_error= config.ipython_warning_is_error
902 909 promptin = config.ipython_promptin
903 910 promptout = config.ipython_promptout
904 911 mplbackend = config.ipython_mplbackend
@@ -906,12 +913,12 b' class IPythonDirective(Directive):'
906 913 hold_count = config.ipython_holdcount
907 914
908 915 return (savefig_dir, source_dir, rgxin, rgxout,
909 promptin, promptout, mplbackend, exec_lines, hold_count)
916 promptin, promptout, mplbackend, exec_lines, hold_count, warning_is_error)
910 917
911 918 def setup(self):
912 919 # Get configuration values.
913 920 (savefig_dir, source_dir, rgxin, rgxout, promptin, promptout,
914 mplbackend, exec_lines, hold_count) = self.get_config_options()
921 mplbackend, exec_lines, hold_count, warning_is_error) = self.get_config_options()
915 922
916 923 try:
917 924 os.makedirs(savefig_dir)
@@ -951,6 +958,7 b' class IPythonDirective(Directive):'
951 958 self.shell.savefig_dir = savefig_dir
952 959 self.shell.source_dir = source_dir
953 960 self.shell.hold_count = hold_count
961 self.shell.warning_is_error = warning_is_error
954 962
955 963 # setup bookmark for saving figures directory
956 964 self.shell.process_input_line('bookmark ipy_savedir %s'%savefig_dir,
@@ -1028,6 +1036,7 b' def setup(app):'
1028 1036
1029 1037 app.add_directive('ipython', IPythonDirective)
1030 1038 app.add_config_value('ipython_savefig_dir', 'savefig', 'env')
1039 app.add_config_value('ipython_warning_is_error', True, 'env')
1031 1040 app.add_config_value('ipython_rgxin',
1032 1041 re.compile('In \[(\d+)\]:\s?(.*)\s*'), 'env')
1033 1042 app.add_config_value('ipython_rgxout',
General Comments 0
You need to be logged in to leave comments. Login now