##// 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 The compiled regular expression to denote the start of IPython input
84 The compiled regular expression to denote the start of IPython input
85 lines. The default is ``re.compile('In \[(\d+)\]:\s?(.*)\s*')``. You
85 lines. The default is ``re.compile('In \[(\d+)\]:\s?(.*)\s*')``. You
86 shouldn't need to change this.
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 ipython_rgxout:
91 ipython_rgxout:
88 The compiled regular expression to denote the start of IPython output
92 The compiled regular expression to denote the start of IPython output
89 lines. The default is ``re.compile('Out\[(\d+)\]:\s?(.*)\s*')``. You
93 lines. The default is ``re.compile('Out\[(\d+)\]:\s?(.*)\s*')``. You
@@ -559,7 +563,8 b' class EmbeddedSphinxShell(object):'
559 sys.stdout.write(s)
563 sys.stdout.write(s)
560 sys.stdout.write(processed_output)
564 sys.stdout.write(processed_output)
561 sys.stdout.write('<<<' + ('-' * 73) + '\n\n')
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 # output any warning raised during execution to stdout
569 # output any warning raised during execution to stdout
565 # unless :okwarning: has been specified.
570 # unless :okwarning: has been specified.
@@ -574,7 +579,8 b' class EmbeddedSphinxShell(object):'
574 w.filename, w.lineno, w.line)
579 w.filename, w.lineno, w.line)
575 sys.stdout.write(s)
580 sys.stdout.write(s)
576 sys.stdout.write('<<<' + ('-' * 73) + '\n')
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 self.cout.truncate(0)
585 self.cout.truncate(0)
580 return (ret, input_lines, processed_output,
586 return (ret, input_lines, processed_output,
@@ -899,6 +905,7 b' class IPythonDirective(Directive):'
899 # get regex and prompt stuff
905 # get regex and prompt stuff
900 rgxin = config.ipython_rgxin
906 rgxin = config.ipython_rgxin
901 rgxout = config.ipython_rgxout
907 rgxout = config.ipython_rgxout
908 warning_is_error= config.ipython_warning_is_error
902 promptin = config.ipython_promptin
909 promptin = config.ipython_promptin
903 promptout = config.ipython_promptout
910 promptout = config.ipython_promptout
904 mplbackend = config.ipython_mplbackend
911 mplbackend = config.ipython_mplbackend
@@ -906,12 +913,12 b' class IPythonDirective(Directive):'
906 hold_count = config.ipython_holdcount
913 hold_count = config.ipython_holdcount
907
914
908 return (savefig_dir, source_dir, rgxin, rgxout,
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 def setup(self):
918 def setup(self):
912 # Get configuration values.
919 # Get configuration values.
913 (savefig_dir, source_dir, rgxin, rgxout, promptin, promptout,
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 try:
923 try:
917 os.makedirs(savefig_dir)
924 os.makedirs(savefig_dir)
@@ -951,6 +958,7 b' class IPythonDirective(Directive):'
951 self.shell.savefig_dir = savefig_dir
958 self.shell.savefig_dir = savefig_dir
952 self.shell.source_dir = source_dir
959 self.shell.source_dir = source_dir
953 self.shell.hold_count = hold_count
960 self.shell.hold_count = hold_count
961 self.shell.warning_is_error = warning_is_error
954
962
955 # setup bookmark for saving figures directory
963 # setup bookmark for saving figures directory
956 self.shell.process_input_line('bookmark ipy_savedir %s'%savefig_dir,
964 self.shell.process_input_line('bookmark ipy_savedir %s'%savefig_dir,
@@ -1028,6 +1036,7 b' def setup(app):'
1028
1036
1029 app.add_directive('ipython', IPythonDirective)
1037 app.add_directive('ipython', IPythonDirective)
1030 app.add_config_value('ipython_savefig_dir', 'savefig', 'env')
1038 app.add_config_value('ipython_savefig_dir', 'savefig', 'env')
1039 app.add_config_value('ipython_warning_is_error', True, 'env')
1031 app.add_config_value('ipython_rgxin',
1040 app.add_config_value('ipython_rgxin',
1032 re.compile('In \[(\d+)\]:\s?(.*)\s*'), 'env')
1041 re.compile('In \[(\d+)\]:\s?(.*)\s*'), 'env')
1033 app.add_config_value('ipython_rgxout',
1042 app.add_config_value('ipython_rgxout',
General Comments 0
You need to be logged in to leave comments. Login now