style: docs snippets formatting#10552
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
anakin87
left a comment
There was a problem hiding this comment.
I investigated a bit but basically came to the same conclusions as you: no existing tools for ruff + docstring; 3 steps are needed.
I'd run this pre-commit hook for all docs in this PR, so that we can also see if it's robust and behaves as expected.
|
@anakin87 That affected more than 2k files, so I decided to open a separate PR targetting this branch: #10554 Preview: https://haystack-docs-git-docs-snippets-formatting-attempt-deepset-ai.vercel.app/docs/ I already noticed some of the code snippets are skipped, so I'm going to investigate that. Example: https://haystack-docs-git-docs-snippets-formatting-attempt-deepset-ai.vercel.app/docs/secret-management#custom-component-example (uses 2 spaces for indent). Edit: the section above actually uses mixed indentation (spaces and tabs), so ruff silently fails on it |
|
Merged the PR, please fix conflicts, and sorry. Basically, |
* feat: allow setting line length * docs: reformat all the documentation pages * Revert "docs: reformat all the documentation pages" This reverts commit 0b36a91. * docs: reformat only .mdx files * docs: rerun formatting with 88 characters per line
6a3847b to
c3a9db1
Compare
This reverts commit c3a9db1.
Related Issues
Proposed Changes:
A new pre-commit hook that automatically formats code snippets in the documentation so we use consistent formatting. It uses the same settings like the entire project, but that might be a topic to discuss, since shorter lines might be better for the website.
How did you test it?
Manually tested with pre-commit.
Notes for the reviewer
I specifically launched it on one page of the documentation, to not clutter the PR. If we want to merge it, we need to rerun on all the documentation pages. I implemented it as a separate script, as I couldn't find any popular tool that would work with ruff, and not black.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.