It would be nice if the notebooks in the docs site adhered to a code format/style guideline. ruff is the industry standard for this purpose so I would recommend using it here.
The simplest way to handle python code would be to add a pre-commit hook that runs ruff format on all of the notebooks, then add a CI check that enforces it.
I am unsure about the preferred style guideline for R code, and it will definitely be trickier to get it to apply formatting to R cells in .ipynb files so I would prefer to handle that task separately.