Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,24 @@ You can disable this behavior by setting the following config:
```python
jupyterlite_bind_ipynb_suffix = False
```


## Build logging levels

Jupyterlite-sphinx exposes jupyterlite debug and logging flags thought the
following configuration options.


- `jupyterlite_debug`, boolean (`False`|`True`), passes the `--debug` flag to
`jupyterlite build`

It also has the following configuration options:

- `jupyterlite_log_level`, a `str` (defaults to `"WARN"`) or `None`
- `jupyterlite_verbosity`, a `str` (defaults to `"0"`) or `None`
- `jupyterlite_reporter`, a `str` (defaults to `"zero"`) or `None`

Jupyterlite-sphinx uses low verbosity by default. Setting these parameters to `None` restores the `jupyterlite build` defaults.

See the `jupyterlite build` documentation for info on `log-level`. `verbosity` and `reporter` control the configuration
of [doit](https://smarie.github.io/python-doit-api/api_reference/), which is used internally in `jupyterlite`.
57 changes: 42 additions & 15 deletions jupyterlite_sphinx/jupyterlite_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,13 @@ def jupyterlite_build(app: Sphinx, error):
print("[jupyterlite-sphinx] Running JupyterLite build")
jupyterlite_config = app.env.config.jupyterlite_config
jupyterlite_contents = app.env.config.jupyterlite_contents
jupyterlite_dir = app.env.config.jupyterlite_dir

jupyterlite_dir = str(app.env.config.jupyterlite_dir)

jupyterlite_debug = app.env.config.jupyterlite_debug
jupyterlite_log_level = app.env.config.jupyterlite_log_level
jupyterlite_verbosity = app.env.config.jupyterlite_verbosity
jupyterlite_reporter = app.env.config.jupyterlite_reporter

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

command = [
"jupyter",
"lite",
"build",
"--debug",
*config,
*contents,
"--contents",
os.path.join(app.srcdir, CONTENT_DIR),
"--output-dir",
os.path.join(app.outdir, JUPYTERLITE_DIR),
*apps_option,
"--lite-dir",
jupyterlite_dir,
c
for c in (
"jupyter",
"lite",
"doit" "build",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Carreau I think you missed a comma here(?).

I don't have time now, but I will try to debug this more tonight US time.

"--debug" if jupyterlite_debug else None,
*config,
*contents,
"--contents",
os.path.join(app.srcdir, CONTENT_DIR),
"--output-dir",
os.path.join(app.outdir, JUPYTERLITE_DIR),
*apps_option,
"--lite-dir",
jupyterlite_dir,
"--log-level" if jupyterlite_log_level is not None else None,
jupyterlite_log_level,
"--",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this -- is also an unintended addition. ?

Copy link

@matthewfeickert matthewfeickert Mar 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.f. PR #152

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's needed to pass the args to doit in jupyterlite build. See jupyterlite/jupyterlite#1351

"--verbosity" if jupyterlite_verbosity else None,
jupyterlite_verbosity,
"--reporter" if jupyterlite_reporter else None,
jupyterlite_reporter,
)
if c is not None
]

assert all(
[isinstance(s, str) for s in command]
), f"Expected all commands arguments to be a str, got {command}"

subprocess.run(command, cwd=app.srcdir, check=True)

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

# Config options
app.add_config_value("jupyterlite_config", None, rebuild="html")
app.add_config_value("jupyterlite_dir", app.srcdir, rebuild="html")
app.add_config_value("jupyterlite_dir", str(app.srcdir), rebuild="html")
app.add_config_value("jupyterlite_contents", None, rebuild="html")
app.add_config_value("jupyterlite_bind_ipynb_suffix", True, rebuild="html")

# JLite debug configuration options
app.add_config_value("jupyterlite_debug", False, rebuild="html")
app.add_config_value("jupyterlite_log_level", "WARN", rebuild="html")
app.add_config_value("jupyterlite_verbosity", "0", rebuild="html")
app.add_config_value("jupyterlite_reporter", "zero", rebuild="html")

app.add_config_value("global_enable_try_examples", default=False, rebuild=True)
app.add_config_value("try_examples_global_theme", default=None, rebuild=True)
app.add_config_value("try_examples_global_warning_text", default=None, rebuild=True)
Expand Down