Skip to content

Commit

Permalink
Exclude current command from its own SEE ALSO section (#172)
Browse files Browse the repository at this point in the history
Also exclude trailing period, as described in `man-pages(7)`.

---------

Signed-off-by: Viktor Söderqvist <[email protected]>
  • Loading branch information
zuiderkwast authored Sep 23, 2024
1 parent 38376fd commit e82084b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/preprocess-markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def print_bottom(self):
print("# SEE ALSO", end="\n\n")
see_also = ", ".join(["**" + cmd.lower().replace(' ', '-') + "**(3valkey)"
for cmd in self.see_also_commands.keys()])
print(see_also + ".", end="\n\n")
print(see_also, end="\n\n")

def rewrite_heading(self, heading):
heading = heading.strip()
Expand Down Expand Up @@ -254,13 +254,13 @@ def acl_categories(json):
acl.add("SLOW")
return ["@" + cat.lower() for cat in sorted(acl)]

def command_see_also(group, commands_per_group_file):
def command_see_also(group, commands_per_group_file, exclude_command):
"""Returns a dict {command: summary} of the commands in the given group"""
commands_per_group = loadjson(commands_per_group_file)
commands = commands_per_group.get(group)
if not commands:
return []
return {k: v.get("summary") for (k, v) in commands.items() if not v.get("deprecated")}
return {k: v.get("summary") for (k, v) in commands.items() if not v.get("deprecated") and k != exclude_command}

def rewrite_links(text, renderer):
def repl_link_match(match):
Expand Down Expand Up @@ -354,7 +354,7 @@ def main():
"history": command_metadata.get("history"),
"acl_categories": acl_categories(command_metadata),
"group": command_metadata.get("group"),
"see_also_commands": command_see_also(command_metadata.get("group"), args.commands_per_group_json)
"see_also_commands": command_see_also(command_metadata.get("group"), args.commands_per_group_json, name)
})
if "deprecated_since" in command_metadata:
data["deprecated_since"] = command_metadata["deprecated_since"]
Expand Down

0 comments on commit e82084b

Please sign in to comment.