fix(markdown): do not drop uppercase namespace classes or parenthesized method mentions
(cherry picked from commit ba55e741f3)
This commit is contained in:
1 parent
107ddf0846
commit
8fcec967ac
2 files changed
+6
-2
No files matched your search
@@ -420,9 +420,10 @@ def _code_span_mention(span: str) -> "tuple[str | None, list[str]] | None":
|
||||
# that is only a namespace root (``App\``) is dropped: it names no symbol.
|
||||
m = _MD_NS_MENTION_RE.match(text)
|
||||
if m:
|
||||
body = text[:-2] if text.endswith("()") else text
|
||||
is_call = text.endswith("()")
|
||||
body = text[:-2] if is_call else text
|
||||
parts = re.split(r"::|\\", body)
|
||||
if _MD_NS_NON_SYMBOL_RE.match(parts[-1]):
|
||||
if not is_call and body.endswith("::" + parts[-1]) and _MD_NS_NON_SYMBOL_RE.match(parts[-1]):
|
||||
return None
|
||||
return None, parts
|
||||
return None
|
||||
|
||||
@@ -97,6 +97,9 @@ def test_code_span_mentions_are_classified():
|
||||
None, ["App", "Services", "Mailer"])
|
||||
assert _code_span_mention("Mailer::send") == (None, ["Mailer", "send"])
|
||||
assert _code_span_mention("Mailer::send()") == (None, ["Mailer", "send"])
|
||||
assert _code_span_mention("App\\Services\\DB") == (None, ["App", "Services", "DB"])
|
||||
assert _code_span_mention("App\\API") == (None, ["App", "API"])
|
||||
assert _code_span_mention("Http::GET()") == (None, ["Http", "GET"])
|
||||
# `Foo::CONST` and `Foo::class` have no node to land on, and a bare
|
||||
# namespace root (`App\`) names no symbol at all.
|
||||
for span in ("Foo::CONST", "Foo::class", "App\\", "C:\\Users\\me"):
|
||||
|
||||
Reference in new issue
Block a user