From d19324df692aa8a7951e3da709a7945e79396d90 Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Wed, 28 Jun 2023 05:57:24 +0530 Subject: [PATCH] Add Jupyter integration to the docs (#5403) ## Summary Add Jupyter integration to the docs, specifically the Configuration and FAQ sections. ## Test Plan `mkdocs serve` and check that the new sections are visible and functional. fixes: #5396 --- docs/configuration.md | 18 ++++++++++++++++++ docs/faq.md | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 20ee6ba11a..3c95d5ca87 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -328,6 +328,24 @@ By default, Ruff will also skip any files that are omitted via `.ignore`, `.giti Files that are passed to `ruff` directly are always linted, regardless of the above criteria. For example, `ruff check /path/to/excluded/file.py` will always lint `file.py`. +## Jupyter Notebook discovery + +Ruff has built-in experimental support for linting [Jupyter Notebooks](https://jupyter.org/). + +To opt in to linting Jupyter Notebook (`.ipynb`) files, add the `*.ipynb` pattern to your +[`include`](settings.md#include) setting, like so: + +```toml +[tool.ruff] +include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"] +``` + +This will prompt Ruff to discover Jupyter Notebook (`.ipynb`) files in any specified +directories, and lint them accordingly. + +Alternatively, pass the notebook file(s) to `ruff` on the command-line directly. For example, +`ruff check /path/to/notebook.ipynb` will always lint `notebook.ipynb`. + ## Rule selection The set of enabled rules is controlled via the [`select`](settings.md#select) and diff --git a/docs/faq.md b/docs/faq.md index e0fe13380a..8d6e7b3652 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -309,7 +309,23 @@ src = ["../src", "../test"] ## Does Ruff support Jupyter Notebooks? -Ruff is integrated into [nbQA](https://github.com/nbQA-dev/nbQA), a tool for running linters and +Ruff has built-in experimental support for linting [Jupyter Notebooks](https://jupyter.org/). + +To opt in to linting Jupyter Notebook (`.ipynb`) files, add the `*.ipynb` pattern to your +[`include`](settings.md#include) setting, like so: + +```toml +[tool.ruff] +include = ["*.py", "*.pyi", "**/pyproject.toml", "*.ipynb"] +``` + +This will prompt Ruff to discover Jupyter Notebook (`.ipynb`) files in any specified +directories, and lint them accordingly. + +Alternatively, pass the notebook file(s) to `ruff` on the command-line directly. For example, +`ruff check /path/to/notebook.ipynb` will always lint `notebook.ipynb`. + +Ruff also integrates with [nbQA](https://github.com/nbQA-dev/nbQA), a tool for running linters and code formatters over Jupyter Notebooks. After installing `ruff` and `nbqa`, you can run Ruff over a notebook like so: