styler
styler copied to clipboard
Support for styling .ipynb (IRKernel)
Would support for styling .ipynb files be in scope for styler? Ideally a flow like styler::style_file('/path/to.ipynb') which extracts the code chunks from the JSON & styles them, then writes back out in the correct JSON format.
I consider this out of scope, mainly because other people already looked into this. E.g. you could use {styler} with the jupyter lab formatter. ~Maybe we should add a note to the~ See thenote in the vignette third-party adoption. Is that what you are looking for?
Another option is contributing a styler integration to prettier.io or coala.io as described in #429, maybe they already have a Jupyter feature to build upon?
You could also use jupytext to save your jupyter notebooks as Rmd or plain R files and apply styler on them.
One reason not to outsource this to Jupyter front-end tooling is that .ipynb is a bit more general format then just Jupyter -- e.g. Colab uses roughly the same format, but it's not clear the same tooling will work interchangeably. Therefore I think it makes some sense for {styler} to own the logic, then the other downstreams can build on that.
Would you accept PR(s) for this? I might do so alongside a similar feature for {lintr}:
https://github.com/r-lib/lintr/issues/383
Yes, I am open to reviewing a PR from you. Other advantage is that in pre-commit, we’ll be able to extend the styler-hook as well.