diff --git a/scripts/set-alias-page.py b/scripts/set-alias-page.py index 2b830a6083..22f676e0ce 100755 --- a/scripts/set-alias-page.py +++ b/scripts/set-alias-page.py @@ -186,11 +186,21 @@ def get_alias_page(path: Path) -> str: if not path.exists(): return "" + + command_count = 0 + command_name = "" + with path.open(encoding="utf-8") as f: for line in f: - # match alias (`tldr `) - if match := re.search(r"^`tldr (.+)`", line): - return match[1] + # match alias page pattern "> This command is an alias of `example`." + if match := re.search(r"^> This command is an alias of `(.+)`\.$", line): + command_name = match[1] + # count the lines matching pattern "`...`" + if re.match(r"^`[^`]+`$", line.strip()): + command_count += 1 + + if command_count == 1: + return command_name return ""