Skip to content

style: docs snippets formatting#10552

Merged
kacperlukawski merged 9 commits intomainfrom
docs-snippets-formatting
Feb 12, 2026
Merged

style: docs snippets formatting#10552
kacperlukawski merged 9 commits intomainfrom
docs-snippets-formatting

Conversation

@kacperlukawski
Copy link
Member

@kacperlukawski kacperlukawski commented Feb 10, 2026

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

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@kacperlukawski kacperlukawski requested a review from a team as a code owner February 10, 2026 14:47
@kacperlukawski kacperlukawski requested review from anakin87 and removed request for a team February 10, 2026 14:47
@vercel
Copy link

vercel bot commented Feb 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
haystack-docs Ready Ready Preview, Comment Feb 12, 2026 0:51am

Request Review

Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kacperlukawski
Copy link
Member Author

kacperlukawski commented Feb 10, 2026

@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

Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work!

I also ran the hook locally and works as expected.

(BTW, I use prek)

Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking to avoid conflicts with #10574 which is part of the release process.

After #10574 is merged (as soon as possible), we also need to rebase this PR.

@anakin87
Copy link
Member

Merged the PR, please fix conflicts, and sorry. Basically, docs-website/versioned_docs/version-2.24-unstable no longer exists: has been promoted to docs-website/versioned_docs/version-2.24.

kacperlukawski and others added 6 commits February 12, 2026 12:53
* 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
@kacperlukawski kacperlukawski force-pushed the docs-snippets-formatting branch from 6a3847b to c3a9db1 Compare February 12, 2026 11:57
Copy link
Member

@anakin87 anakin87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@kacperlukawski kacperlukawski merged commit 8197a6d into main Feb 12, 2026
11 checks passed
@kacperlukawski kacperlukawski deleted the docs-snippets-formatting branch February 12, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants