fix(markdown): do not drop uppercase namespace classes or parenthesized method mentions

This commit is contained in:
Aditya kumar singh committed 2026-11-08 16:51:26 +05:30
1 parent 6c8002eca4
commit ba55e741f3
2 files changed
+6 -2

No files matched your search

+3 -2
View File
@@ -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
+3
View File
@@ -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"):