@@ -548,11 +548,6 @@ def jupyterlite_build(app: Sphinx, error):
548548
549549 jupyterlite_dir = str (app .env .config .jupyterlite_dir )
550550
551- jupyterlite_debug = app .env .config .jupyterlite_debug
552- jupyterlite_log_level = app .env .config .jupyterlite_log_level
553- jupyterlite_verbosity = app .env .config .jupyterlite_verbosity
554- jupyterlite_reporter = app .env .config .jupyterlite_reporter
555-
556551 config = []
557552 if jupyterlite_config :
558553 config = ["--config" , jupyterlite_config ]
@@ -580,37 +575,48 @@ def jupyterlite_build(app: Sphinx, error):
580575 apps_option .extend (["--apps" , "voici" ])
581576
582577 command = [
583- c
584- for c in (
585- "jupyter" ,
586- "lite" ,
587- "doit" "build" ,
588- "--debug" if jupyterlite_debug else None ,
589- * config ,
590- * contents ,
591- "--contents" ,
592- os .path .join (app .srcdir , CONTENT_DIR ),
593- "--output-dir" ,
594- os .path .join (app .outdir , JUPYTERLITE_DIR ),
595- * apps_option ,
596- "--lite-dir" ,
597- jupyterlite_dir ,
598- "--log-level" if jupyterlite_log_level is not None else None ,
599- jupyterlite_log_level ,
600- "--" ,
601- "--verbosity" if jupyterlite_verbosity else None ,
602- jupyterlite_verbosity ,
603- "--reporter" if jupyterlite_reporter else None ,
604- jupyterlite_reporter ,
605- )
606- if c is not None
578+ "jupyter" ,
579+ "lite" ,
580+ "build" ,
581+ "--debug" ,
582+ * config ,
583+ * contents ,
584+ "--contents" ,
585+ os .path .join (app .srcdir , CONTENT_DIR ),
586+ "--output-dir" ,
587+ os .path .join (app .outdir , JUPYTERLITE_DIR ),
588+ * apps_option ,
589+ "--lite-dir" ,
590+ jupyterlite_dir ,
607591 ]
608592
609593 assert all (
610594 [isinstance (s , str ) for s in command ]
611595 ), f"Expected all commands arguments to be a str, got { command } "
612596
613- subprocess .run (command , cwd = app .srcdir , check = True )
597+ kwargs = {"cwd" : app .srcdir , "check" : False }
598+ if app .env .config .jupyterlite_silence :
599+ kwargs ["stdout" ] = subprocess .PIPE
600+ kwargs ["stderr" ] = subprocess .PIPE
601+
602+ completed_process = subprocess .run (command , ** kwargs )
603+
604+ if completed_process .returncode != 0 :
605+ if app .env .config .jupyterlite_silence :
606+ print (
607+ "`jupyterlite build` failed but it's output has been silenced."
608+ " stdout and stderr are reproduced below.\n "
609+ )
610+ print ("stdout:" , completed_process .stdout .decode ())
611+ print ("stderr:" , completed_process .stderr .decode ())
612+
613+ # Raise the original exception that would have occurred with check=True
614+ raise subprocess .CalledProcessError (
615+ returncode = completed_process .returncode ,
616+ cmd = command ,
617+ output = completed_process .stdout ,
618+ stderr = completed_process .stderr ,
619+ )
614620
615621 print ("[jupyterlite-sphinx] JupyterLite build done" )
616622
@@ -635,12 +641,7 @@ def setup(app):
635641 app .add_config_value ("jupyterlite_dir" , str (app .srcdir ), rebuild = "html" )
636642 app .add_config_value ("jupyterlite_contents" , None , rebuild = "html" )
637643 app .add_config_value ("jupyterlite_bind_ipynb_suffix" , True , rebuild = "html" )
638-
639- # JLite debug configuration options
640- app .add_config_value ("jupyterlite_debug" , False , rebuild = "html" )
641- app .add_config_value ("jupyterlite_log_level" , "WARN" , rebuild = "html" )
642- app .add_config_value ("jupyterlite_verbosity" , "0" , rebuild = "html" )
643- app .add_config_value ("jupyterlite_reporter" , "zero" , rebuild = "html" )
644+ app .add_config_value ("jupyterlite_silence" , True , rebuild = True )
644645
645646 app .add_config_value ("global_enable_try_examples" , default = False , rebuild = True )
646647 app .add_config_value ("try_examples_global_theme" , default = None , rebuild = True )
0 commit comments