Skip to content

Commit

Permalink
DX: describe jupyterlab-code-formatter Ruff settings (#287)
Browse files Browse the repository at this point in the history
* FIX: update link to CI workflow
  • Loading branch information
redeboer authored Aug 1, 2024
1 parent 090f458 commit b0885ba
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion docs/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pre-commit run -a

Whenever you {ref}`submit a pull request <develop:Collaboration>`, this command is
automatically run
[on GitHub actions](https://github.com/ComPWA/ampform/actions/workflows/ci-style.yml)
[on GitHub actions](https://github.com/ComPWA/ampform/actions/workflows/ci.yml)
and [on pre-commit.ci](https://results.pre-commit.ci/install/github/18435973) , ensuring
that all files in the repository follow the same conventions as set in the config files
of these tools.
Expand Down Expand Up @@ -637,6 +637,27 @@ EXECUTE_NB= tox -e doclive

:::{tip}
Notebooks are automatically formatted through {ref}`pre-commit <develop:Pre-commit>` (see {ref}`develop:Formatting`). If you want to format the notebooks automatically as you're working, you can do so with [`jupyterlab-code-formatter`](https://jupyterlab-code-formatter.readthedocs.io), which is automatically {ref}`installed with the dev requirements <develop:Optional dependencies>`.

For this, you need to set Ruff as the formatter (see [](#formatting)) for `jupyterlab-code-formatter`:

1. Open Jupyter Lab Settings ({kbd}`Ctrl+,` / {kbd}`⌘+,`).
2. Select the "Jupyterlab Code Formatter" plugin from the left sidebar.
3. Under `default_formatter`, list two Python formatters: `ruffformat` and `ruff`. The first is the actual [Ruff formatter](https://docs.astral.sh/ruff/formatter) that mimics `black`, the second is for Ruff auto-fixes of linting rules. (The default formatters are `isort` and `black`—you should overwrite these.) <!-- cspell:ignore ruffformat -->
4. **Optional:** Activate format-on-save by ticking "Auto format config".

Alternatively, you can open the settings for the "Jupyterlab Code Formatter" as JSON and set it to:

```json
{
"preferences": {
"default_formatter": {
"python": ["ruffformat", "ruff"]
}
},
"formatOnSave": true
}
```

:::

#### IJulia notebooks
Expand Down

0 comments on commit b0885ba

Please sign in to comment.