Skip to content

Commit

Permalink
Merge pull request #208 from daizutabi/207-correct-the-title-for-the-…
Browse files Browse the repository at this point in the history
…go-to-definition-buttons

Correct the title for the "Go to definition" buttons
  • Loading branch information
daizutabi authored Sep 23, 2024
2 parents d401dcf + 46928b0 commit 8091726
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/mkapi/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,16 @@ def _link(match: re.Match, src_uri: str, namespace: str) -> str:
if name.startswith("`") and name.endswith("`"):
fullname = name[1:-1]

asname = ""
asname = title = ""

if m := OBJECT_LINK_PATTERN.match(fullname):
is_object_link = True
namespace, fullname = m.groups()

if namespace == "definition" and "object" in URIS:
name = ANCHOR_PLACEHOLDERS["definition"]
name = ANCHOR_PLACEHOLDERS[namespace]
title = ANCHOR_TITLES[namespace]
namespace = "object"

elif namespace in ANCHOR_PLACEHOLDERS and namespace in URIS:
name = ANCHOR_PLACEHOLDERS[namespace]
else:
Expand All @@ -201,7 +201,8 @@ def _link(match: re.Match, src_uri: str, namespace: str) -> str:
if uri := URIS[namespace].get(fullname):
uri = os.path.relpath(uri, PurePath(src_uri).parent)
uri = uri.replace("\\", "/") # Normalize for Windows
title = ANCHOR_TITLES[namespace] if is_object_link else fullname
if not title:
title = ANCHOR_TITLES[namespace] if is_object_link else fullname
return f'[{name}]({uri}#{fullname} "{title}")'

if from_mkapi and name != ANCHOR_PLACEHOLDERS["definition"]:
Expand Down

0 comments on commit 8091726

Please sign in to comment.