Skip to content

Commit

Permalink
Allow {{Foo/bar}} to link to bar(arg), like {{Foo/bar()}} can.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Oct 3, 2024
1 parent 828e63d commit 0201837
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bikeshed/refs/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,13 @@ def forRefsIterator(targetFors: str | list[str]) -> t.Generator[t.RefWrapper, No
refs = list(textRefsIterator([text]))
else:
textsToSearch = list(utils.linkTextVariations(text, linkType))
if text.endswith("()") and text in self.methods:
textsToSearch += list(self.methods[text].variants.keys())

if any(st.endswith("()") for st in textsToSearch):
# Let argless methods (either with () at the end, or no parens at all)
# pull in their argful variants for searching.
for st in textsToSearch[:]:
textsToSearch += getArgfulMethodVariants(st, self)

if (linkType is None or linkType in config.lowercaseTypes) and text.lower() != text:
textsToSearch += [t.lower() for t in textsToSearch]
refs = list(textRefsIterator(textsToSearch))
Expand Down Expand Up @@ -400,6 +405,12 @@ def decodeAnchors(linesIter: t.Iterator[str]) -> defaultdict[str, list[t.RefWrap
return anchors


def getArgfulMethodVariants(maybeMethodSig: str, refs: RefSource) -> list[str]:
if maybeMethodSig.endswith("()") and maybeMethodSig in refs.methods:
return list(refs.methods[maybeMethodSig].variants.keys())
return []


@dataclasses.dataclass
class MethodVariants:
arglessSignature: str
Expand Down

0 comments on commit 0201837

Please sign in to comment.