From 606c2f50bac943ca12adf91967fc6e9ec3cb9a71 Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Wed, 19 May 2021 12:58:48 +0100 Subject: [PATCH] [Help] Strip docstrings before shortening them (#4983) * [Help] Strip docstrings before shortening them * [Help] Use rstrip instead of full strip --- redbot/core/commands/help.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index c68872cce..afd13e891 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -380,7 +380,7 @@ class RedHelpFormatter(HelpFormatterABC): def shorten_line(a_line: str) -> str: if len(a_line) < 70: # embed max width needs to be lower return a_line - return a_line[:67] + "..." + return a_line[:67].rstrip() + "..." subtext = "\n".join( shorten_line(f"**{name}** {command.format_shortdoc_for_context(ctx)}") @@ -410,7 +410,7 @@ class RedHelpFormatter(HelpFormatterABC): width_gap = discord.utils._string_width(nm) - len(nm) doc = com.format_shortdoc_for_context(ctx) if len(doc) > doc_max_width: - doc = doc[: doc_max_width - 3] + "..." + doc = doc[: doc_max_width - 3].rstrip() + "..." yield nm, doc, max_width - width_gap subtext = "\n".join( @@ -555,7 +555,7 @@ class RedHelpFormatter(HelpFormatterABC): def shorten_line(a_line: str) -> str: if len(a_line) < 70: # embed max width needs to be lower return a_line - return a_line[:67] + "..." + return a_line[:67].rstrip() + "..." command_text = "\n".join( shorten_line(f"**{name}** {command.format_shortdoc_for_context(ctx)}") @@ -584,7 +584,7 @@ class RedHelpFormatter(HelpFormatterABC): width_gap = discord.utils._string_width(nm) - len(nm) doc = com.format_shortdoc_for_context(ctx) if len(doc) > doc_max_width: - doc = doc[: doc_max_width - 3] + "..." + doc = doc[: doc_max_width - 3].rstrip() + "..." yield nm, doc, max_width - width_gap subtext = "\n".join( @@ -622,7 +622,7 @@ class RedHelpFormatter(HelpFormatterABC): def shorten_line(a_line: str) -> str: if len(a_line) < 70: # embed max width needs to be lower return a_line - return a_line[:67] + "..." + return a_line[:67].rstrip() + "..." cog_text = "\n".join( shorten_line(f"**{name}** {command.format_shortdoc_for_context(ctx)}") @@ -655,7 +655,7 @@ class RedHelpFormatter(HelpFormatterABC): width_gap = discord.utils._string_width(nm) - len(nm) doc = com.format_shortdoc_for_context(ctx) if len(doc) > doc_max_width: - doc = doc[: doc_max_width - 3] + "..." + doc = doc[: doc_max_width - 3].rstrip() + "..." yield nm, doc, max_width - width_gap for cog_name, data in coms: