Fix #107265: Compositor: output node remove note that z-depth can be saved #104457
@ -49,39 +49,53 @@ def check_word(w):
|
|||||||
return dict_spelling.check(w)
|
return dict_spelling.check(w)
|
||||||
|
|
||||||
|
|
||||||
|
# Match HTML link `Text <url>`__
|
||||||
|
# A URL may span multiple lines.
|
||||||
|
RE_URL_LINKS = re.compile(r"(`)([^`<]+)(<[^`>]+>)(`)(__)", re.MULTILINE)
|
||||||
|
|
||||||
|
# Match `|substitution|` for removal.
|
||||||
|
RE_SUBST = re.compile(r"\|[a-zA-Z0-9_]+\|")
|
||||||
|
|
||||||
|
# :some_role:`Text <ref>`
|
||||||
|
RE_ROLE_WITH_TEXT = re.compile(r"(:[A-Za-z_]+:)(`)([^`<]+)(<[^`>]+>)(`)", flags=re.MULTILINE)
|
||||||
|
|
||||||
|
RE_ROLE_INCLUDE = re.compile(r"(:(menuselection|guilabel):)(`)([^`]+)(`)", flags=re.MULTILINE)
|
||||||
|
RE_ROLE_EXCLUDE = re.compile(r"(:(kbd|ref|doc|abbr):)(`)([^`]+)(`)", flags=re.MULTILINE)
|
||||||
|
|
||||||
|
RE_ROLE_ANY = re.compile(r"(:[A-Za-z_]+:)(`)([^`]+)(`)", flags=re.MULTILINE)
|
||||||
|
|
||||||
|
RE_WORDS = re.compile(
|
||||||
|
r"\b("
|
||||||
|
# Capital words, with optional '-' and "'".
|
||||||
|
r"[A-Z]+[\-'A-Z]*[A-Z]|"
|
||||||
|
# Lowercase words, with optional '-' and "'".
|
||||||
|
r"[A-Za-z][\-'a-z]*[a-z]+"
|
||||||
|
r")\b"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def regex_key_raise(x):
|
||||||
|
raise Exception("Unknown role! " + "".join(x.groups()))
|
||||||
|
|
||||||
|
|
||||||
def check_spelling_body(text):
|
def check_spelling_body(text):
|
||||||
for w in text.split():
|
|
||||||
# skip directive args (e.g. figure target), could do differently?
|
|
||||||
if w.startswith(":") and w.endswith(":"):
|
|
||||||
continue
|
|
||||||
if w.startswith("<") and w.endswith(">"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
w = w.strip("{}[](),.!?;\"'1234567890-_*")
|
text = re.sub(RE_URL_LINKS, lambda x: x.groups()[1].strip(), text)
|
||||||
|
text = re.sub(RE_ROLE_WITH_TEXT, lambda x: x.groups()[2].strip(), text)
|
||||||
|
text = re.sub(RE_ROLE_INCLUDE, lambda x: x.groups()[3].strip(), text)
|
||||||
|
|
||||||
if w.startswith(":") and w.endswith(":"):
|
text = re.sub(RE_ROLE_EXCLUDE, lambda _: " ", text)
|
||||||
continue
|
text = re.sub(RE_ROLE_ANY, regex_key_raise, text)
|
||||||
if w.startswith("<") and w.endswith(">"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# skip character and name entities
|
# Remove substitutions.
|
||||||
if w.startswith("\\") or w.startswith("|"):
|
text = re.sub(RE_SUBST, lambda _: " ", text)
|
||||||
continue
|
|
||||||
|
|
||||||
# now we've gotten rid of typical roles, strip other chars
|
for re_match in RE_WORDS.finditer(text):
|
||||||
w = w.strip(":`()<>{}.,")
|
w = re_match.group(0)
|
||||||
|
|
||||||
# skip python references
|
# Skip entirely uppercase words.
|
||||||
if w.startswith("bpy."):
|
# These are typically used for acronyms: XYZ, UDIM, API ... etc.
|
||||||
continue
|
if w.isupper():
|
||||||
|
|
||||||
# skip document references and keyboard shortcuts
|
|
||||||
if w.startswith(("doc:", "kbd:", "menuselection:", "ref:", "https:", "http:", "abbr:")):
|
|
||||||
continue
|
|
||||||
|
|
||||||
w_ = w
|
|
||||||
for w in w_.split("/"):
|
|
||||||
if not w:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
w_lower = w.lower()
|
w_lower = w.lower()
|
||||||
|
Loading…
Reference in New Issue
Block a user