Skip to content

Halve the time to build docs locally by inlining spell checking - #74549

Merged
ashb merged 3 commits into
mainfrom
single-pass-spelling
Oct 12, 2026
Merged

ashb merged 3 commits into
mainfrom
single-pass-spelling

Conversation

@ashb

@ashb ashb commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Previously to see the same error in docs build as you would get in CI,
you would have to run both the docs build and the spellchecking build.

The issue was that the spellcheck (using sphinx-contrib's spelling) was
defined as a new builder, meaning you could either build HTML, or you
can check spelling. On CI, this didn't result in any extra wall-clock
time as the jobs were parallelized (but this change does remove a job
from the overall matrix), but locally that was almost always not the
case, so this would mean full build to view the HTML, and spell checking
build to look for errors, resulting in it taking twice as long.

The upstream spellchecker was also slower than it should be mainly
because its importable-module filter calls find_spec on every distinct
identifier-like word before consulting the dictionary. Here it runs only
for words that are still misspelled. Word lists, filters and
:spelling:ignore: behave as before.

This also handles errors a lot more nicely (hence all the code deletions):

  • They are written natively to a JSON file, not scraped from a stream
  • They also show up as GH annotations (Where we can attribute it to a
    real file) to make fixing them easier on PRs.

Please note: this is lightly breaking for Airflow contributors as
breeze build-docs --docs-only and --spellcheck-only are gone --
every build checks spelling now as it is essentially free (on the order
of milliseconds per module).

Screenshot 2026-10-10 at 23 24 42
Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@potiuk

potiuk commented Oct 11, 2026

Copy link
Copy Markdown
Member

WHOA !! Fantastic !! Thanks @ashb !!!!

@potiuk

potiuk commented Oct 11, 2026

Copy link
Copy Markdown
Member

And you can see the errors in CI !! . We should have thought about it way before !!!

@ashb

ashb commented Oct 11, 2026

Copy link
Copy Markdown
Member Author

And you can see the errors in CI !! . We should have thought about it way before !!!

I honestly thought this would be way more difficult than it was. I had a lot of time waiting keeping an eye on the Task Loops stack (now thankfully landed!) and yeah, this turned out to be much easier.

The one caveat to the error annotations: These do not ("cannot" right now) show up for generated API docs, as we don't have a way to to map api docs to source file it came from

Comment thread devel-common/src/sphinx_exts/airflow_spelling.py Outdated

@Andrushika Andrushika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WOW, thanks! Left one comment, there's one small detail that makes the new check give a different result from the old one.

@ashb
ashb force-pushed the single-pass-spelling branch from 733b47b to d05147d Compare October 12, 2026 09:23

@Andrushika Andrushika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another super edge case found by my agent, but I would say it's non-blocking, since I couldn't find any existing example in our docs: an identifier followed by ... passes on main, but would fail after this PR.

example: isinstance...

main:     isinstance...  → isinstance   → skipped (builtin)
this PR:  isinstance…    → isinstance…  → reported

(SmartQuotes turns ... into …)

Previously to see the same error in docs build as you would get in CI,
you would have to run both the docs build and the spellchecking build.

The issue was that the spellcheck (using sphinx-contrib's spelling) was
defined as a new builder, meaning you could either build HTML, or you
can check spelling. On CI, this didn't result in any extra wall-clock
time as the jobs were parallelized (but this change does remove a job
from the overall matrix), but locally that was almost always not the
case, so this would mean full build to view the HTML, and spell checking
build to look for errors, resulting in it taking twice as long.

The upstream spellchecker was also slower than it should be mainly
because its importable-module filter calls find_spec on every distinct
identifier-like word before consulting the dictionary. Here it runs only
for words that are still misspelled. Word lists, filters and
`:spelling:ignore:` behave as before.

This also handles errors a lot more nicely (hence all the code deletions):
- They are written natively to a JSON file, not scraped from a stream
- They also show up as GH annotations (Where we can attribute it to a
  real file) to make fixing them easier on PRs.

Please note: this is lightly breaking for Airflow contributors as
`breeze build-docs --docs-only` and `--spellcheck-only` are gone --
every build checks spelling now as it is essentially free (on the order
of milliseconds per module).
@ashb
ashb force-pushed the single-pass-spelling branch from d05147d to fe95212 Compare October 12, 2026 10:41
@ashb

ashb commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Updated to unsmarten anything smartquotes did.

@Andrushika

Copy link
Copy Markdown
Contributor

Thanks :)
If #protm counts nomination from non-committers, this one gets mine haha

Comment thread devel-common/tests/unit/sphinx_exts/test_airflow_spelling.py Outdated
Comment thread .github/workflows/publish-docs-to-s3.yml
Comment thread dev/breeze/doc/03_developer_tasks.rst
@kaxil

kaxil commented Oct 12, 2026

Copy link
Copy Markdown
Member

#protm

@ashb
ashb requested a review from Miretpl as a code owner October 12, 2026 14:47
@ashb

ashb commented Oct 12, 2026

Copy link
Copy Markdown
Member Author

Thanks :) If #protm counts nomination from non-committers, this one gets mine haha

It only needs one nomination from anyone to get on the list, then the vote happens on the mailing list towards end of month, and yes, votes from everyone count there.

@ashb
ashb merged commit 46e20a1 into main Oct 12, 2026
158 checks passed
@ashb
ashb deleted the single-pass-spelling branch October 12, 2026 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants