Skip to content

Commit 4dd4b30

Browse files
authored
Merge pull request #150 from Carreau/verbose
Set lower default verbosity and add config options.
2 parents 36f3f6e + 1b3274b commit 4dd4b30

File tree

2 files changed

+63
-15
lines changed

2 files changed

+63
-15
lines changed

docs/configuration.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,24 @@ You can disable this behavior by setting the following config:
6363
```python
6464
jupyterlite_bind_ipynb_suffix = False
6565
```
66+
67+
68+
## Build logging levels
69+
70+
Jupyterlite-sphinx exposes jupyterlite debug and logging flags thought the
71+
following configuration options.
72+
73+
74+
- `jupyterlite_debug`, boolean (`False`|`True`), passes the `--debug` flag to
75+
`jupyterlite build`
76+
77+
It also has the following configuration options:
78+
79+
- `jupyterlite_log_level`, a `str` (defaults to `"WARN"`) or `None`
80+
- `jupyterlite_verbosity`, a `str` (defaults to `"0"`) or `None`
81+
- `jupyterlite_reporter`, a `str` (defaults to `"zero"`) or `None`
82+
83+
Jupyterlite-sphinx uses low verbosity by default. Setting these parameters to `None` restores the `jupyterlite build` defaults.
84+
85+
See the `jupyterlite build` documentation for info on `log-level`. `verbosity` and `reporter` control the configuration
86+
of [doit](https://smarie.github.io/python-doit-api/api_reference/), which is used internally in `jupyterlite`.

jupyterlite_sphinx/jupyterlite_sphinx.py

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,13 @@ def jupyterlite_build(app: Sphinx, error):
545545
print("[jupyterlite-sphinx] Running JupyterLite build")
546546
jupyterlite_config = app.env.config.jupyterlite_config
547547
jupyterlite_contents = app.env.config.jupyterlite_contents
548-
jupyterlite_dir = app.env.config.jupyterlite_dir
548+
549+
jupyterlite_dir = str(app.env.config.jupyterlite_dir)
550+
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
549555

550556
config = []
551557
if jupyterlite_config:
@@ -574,21 +580,36 @@ def jupyterlite_build(app: Sphinx, error):
574580
apps_option.extend(["--apps", "voici"])
575581

576582
command = [
577-
"jupyter",
578-
"lite",
579-
"build",
580-
"--debug",
581-
*config,
582-
*contents,
583-
"--contents",
584-
os.path.join(app.srcdir, CONTENT_DIR),
585-
"--output-dir",
586-
os.path.join(app.outdir, JUPYTERLITE_DIR),
587-
*apps_option,
588-
"--lite-dir",
589-
jupyterlite_dir,
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
590607
]
591608

609+
assert all(
610+
[isinstance(s, str) for s in command]
611+
), f"Expected all commands arguments to be a str, got {command}"
612+
592613
subprocess.run(command, cwd=app.srcdir, check=True)
593614

594615
print("[jupyterlite-sphinx] JupyterLite build done")
@@ -611,10 +632,16 @@ def setup(app):
611632

612633
# Config options
613634
app.add_config_value("jupyterlite_config", None, rebuild="html")
614-
app.add_config_value("jupyterlite_dir", app.srcdir, rebuild="html")
635+
app.add_config_value("jupyterlite_dir", str(app.srcdir), rebuild="html")
615636
app.add_config_value("jupyterlite_contents", None, rebuild="html")
616637
app.add_config_value("jupyterlite_bind_ipynb_suffix", True, rebuild="html")
617638

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+
618645
app.add_config_value("global_enable_try_examples", default=False, rebuild=True)
619646
app.add_config_value("try_examples_global_theme", default=None, rebuild=True)
620647
app.add_config_value("try_examples_global_warning_text", default=None, rebuild=True)

0 commit comments

Comments
 (0)