Skip to content

Commit 380b394

Browse files
committed
Use a hack to suppress logging
1 parent 3bcf6bc commit 380b394

File tree

1 file changed

+19
-36
lines changed

1 file changed

+19
-36
lines changed

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -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,30 @@ 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": True}
598+
if app.env.config.jupyterlite_silence:
599+
kwargs["stdout"] = subprocess.DEVNULL
600+
kwargs["stderr"] = subprocess.DEVNULL
601+
subprocess.run(command, **kwargs)
614602

615603
print("[jupyterlite-sphinx] JupyterLite build done")
616604

@@ -635,12 +623,7 @@ def setup(app):
635623
app.add_config_value("jupyterlite_dir", str(app.srcdir), rebuild="html")
636624
app.add_config_value("jupyterlite_contents", None, rebuild="html")
637625
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")
626+
app.add_config_value("jupyterlite_silence", False, rebuild=True)
644627

645628
app.add_config_value("global_enable_try_examples", default=False, rebuild=True)
646629
app.add_config_value("try_examples_global_theme", default=None, rebuild=True)

0 commit comments

Comments
 (0)