@@ -64,33 +64,6 @@ def run(self):
64
64
return [addnodes .desc_name (text = member_name ), addnodes .desc_content ("" , literal )]
65
65
66
66
67
- # Sphinx builder specific events hook
68
-
69
-
70
- def check_example_error (app : Sphinx , pagename : str , templatename :str , context :dict [str , Any ], doctree : document ):
71
- """Log an error if the execution of an example as a notebook triggered an error.
72
-
73
- Since the documentation build might not stop if the execution of a notebook triggered
74
- an error, we use a flag to log that an error is spotted in the html page context.
75
- """
76
- # Check if the HTML contains an error message
77
- if pagename .startswith ("examples" ) and not pagename .endswith ("/index" ):
78
- if any (
79
- map (
80
- lambda msg : msg in context ["body" ],
81
- [
82
- "UsageError" ,
83
- "NameError" ,
84
- "DeadKernelError" ,
85
- "NotebookError" ,
86
- "CellExecutionError" ,
87
- ],
88
- )
89
- ):
90
- logger .error (f"An error was detected in file { pagename } " )
91
- app .builder .config .html_context ["build_error" ] = True
92
-
93
-
94
67
# Sphinx generic event hooks
95
68
96
69
@@ -227,8 +200,8 @@ def check_build_finished_without_error(app: Sphinx, exception: None | Exception)
227
200
exception : None or Exception
228
201
Exception raised during the build process.
229
202
"""
230
- if app . builder . config . html_context . get ( "build_error" , False ) :
231
- logger .info ("Build failed due to an error in html-page-context " )
203
+ if exception is not None :
204
+ logger .error ("Build failed due to an error. " )
232
205
exit (1 )
233
206
234
207
def remove_doctree (app : Sphinx , exception : None | Exception ):
@@ -261,8 +234,6 @@ def setup(app):
261
234
Sphinx instance containing all the configuration for the documentation build.
262
235
"""
263
236
app .add_directive ("pprint" , PrettyPrintDirective )
264
- # Builder specific hook
265
- app .connect ("html-page-context" , check_example_error )
266
237
# Builder inited hooks
267
238
app .connect ("builder-inited" , copy_examples )
268
239
app .connect ("builder-inited" , check_pandoc_installed )
0 commit comments