Use yapf
to autoformat the Altair specifications in docs and examples
#3673
Labels
yapf
to autoformat the Altair specifications in docs and examples
#3673
What is your suggestion?
As said by @dangotbanned in #3544 (review):
Everybody prefers autoformatted Altair specifications in the docs and in the examples. Let’s hope we can finish this discussion using the described approach🙏
Adapted from #3630 (comment)
altair/sphinxext/code_ref.py
Line 243 in ed40320
The addition of
CodeRefDirective
allows directly referencing the contents of a function in the docs.There is also some interesting stuff in https://github.com/vega/altair/blob/main/tools/codemod.py that can be adapted to support this use case.
The short explanation is this supports rewriting & reformatting code to be used elsewhere.
So this would have the benefit of writing in the same style as the rest of
altair
code, but support autoformatting for a possibly different style if agreed upon in #3519.More generally though, a move towards writing code blocks in
.py
vs.rst
has other benefits from a maintenance perspective:ruff
,mypy
to ensure code qualityHave you considered any alternative solutions?
ruff
it.ruff
also provides autoformatting, but the proposed style by ruff deviates a bit from manually written specifications (See thread).There is also a second alternative using
ruff
, which was mentioned in #3570 (reply in thread)It may be helpful to compare the effect each tool/config has on a sample of the examples.
Note
Edited by @dangotbanned
The text was updated successfully, but these errors were encountered: