ashb commented on code in PR #74549:
URL: https://github.com/apache/airflow/pull/74549#discussion_r4246218489


##########
devel-common/src/sphinx_exts/airflow_spelling.py:
##########
@@ -0,0 +1,197 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""
+Spell check every document while the html builder writes it.
+
+``sphinxcontrib.spelling`` ships a separate ``spelling`` builder, which means 
building every package
+twice. This extension runs the same checks - its tokenizer, filters, 
dictionary, word lists and the
+``spelling`` domain's directive and roles - on each resolved doctree of the 
html build instead, and
+writes what it finds to the JSON file named by the ``airflow_spelling_output`` 
config value. Leaving
+that value empty disables the check.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+import re
+import tempfile
+from collections.abc import Iterator, Sequence
+from pathlib import Path
+from typing import TYPE_CHECKING, Any
+
+import enchant
+from docutils import nodes
+from docutils.utils import get_source_line
+from enchant.tokenize import EmailFilter, WikiWordFilter, get_tokenizer
+from sphinx.util.matching import Matcher
+from sphinxcontrib.spelling import filters
+from sphinxcontrib.spelling.builder import SpellingBuilder
+
+if TYPE_CHECKING:
+    from docutils.parsers.rst.states import Inliner
+    from sphinx.application import Sphinx
+    from sphinx.config import Config
+    from sphinx.environment import BuildEnvironment
+
+# Enchant's tokenizer starts by splitting on whitespace, so a 
whitespace-delimited chunk is checked the
+# same way on its own as within its paragraph.
+_CHUNK = re.compile(r"\S+")
+# SmartQuotes curls single quotes, and the tokenizer and filters only 
understand ASCII ones: it would split
+# "didn’t" into "didn" and "t", and WikiWordFilter would not skip 
"‘ClusterGenerator’".
+_ASCII_SINGLE_QUOTES = str.maketrans("‘’", "''")

Review Comment:
   I'll double check this, but I think it was fine as the tokenizer already 
splits on non-word characters.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to