Skip to content

Commit

Permalink
Only do the 'assume it might be a method' thing if it has a for value.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Oct 3, 2024
1 parent 0201837 commit 944ec4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bikeshed/refs/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def forRefsIterator(targetFors: str | list[str]) -> t.Generator[t.RefWrapper, No
if exact:
refs = list(textRefsIterator([text]))
else:
textsToSearch = list(utils.linkTextVariations(text, linkType))
textsToSearch = list(utils.linkTextVariations(text, linkType, linkFor))

if any(st.endswith("()") for st in textsToSearch):
# Let argless methods (either with () at the end, or no parens at all)
Expand Down
6 changes: 4 additions & 2 deletions bikeshed/refs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def filterOldVersions(refs: list[t.RefWrapper], status: str | None = None) -> li
return refs


def linkTextVariations(str: str, linkType: str | None) -> t.Generator[str, None, None]:
def linkTextVariations(str: str, linkType: str | None, linkFor: str | None = None) -> t.Generator[str, None, None]:
# Generate intelligent variations of the provided link text,
# so explicitly adding an lt attr isn't usually necessary.
str = str.strip()
Expand Down Expand Up @@ -172,7 +172,9 @@ def linkTextVariations(str: str, linkType: str | None) -> t.Generator[str, None,

# Let people refer to methods without the parens.
# Since attrs and methods live in the same namespace, this is safe.
if "(" not in str:
# But we want to avoid *other* confusions, like an interface and its constructor,
# so qualify it on there being a for value.
if linkFor and "(" not in str:
yield str + "()"

# Allow linking to an enum-value with or without quotes
Expand Down

0 comments on commit 944ec4f

Please sign in to comment.