Ejemplo n.º 1
0
    def format(self):
        self._paginator = Paginator()

        description = self.command.description if not self.is_cog() else None

        if description:
            # <description> portion
            self._paginator.add_line(description, empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(signature, empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        self._paginator.add_line('Commands:')
        self._add_subcommands_to_page(max_width, self.filter_command_list())

        self._paginator.add_line()
        return self._paginator.pages
Ejemplo n.º 2
0
    def format(self):
        """Handles the actual behavior involved with formatting.
        To change the behavior, this method should be overridden.
        Returns
        --------
        list
            A paginated output of the help command.
        """
        self._paginator = Paginator(prefix='', suffix='')

        # we need a padding of ~80 or so
        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(description, empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line('```' + signature, empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(self.command.help + '```')

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return '**__' + cog + '__**:' if cog is not None else '\u200b**__No Category:__**'

        if self.is_bot():
            data = sorted(self.filter_command_list(), key=category)
            for category, commands in itertools.groupby(data, key=category):
                # there simply is no prettier way of doing this.
                commands = list(commands)
                if len(commands) > 0:
                    self._paginator.add_line(category)

                self._add_subcommands_to_page(max_width, commands)
        else:
            self._paginator.add_line('**__Commands__**:')
            self._add_subcommands_to_page(max_width,
                                          self.filter_command_list())

        # add the ending note
        self._paginator.add_line()
        ending_note = self.get_ending_note()
        self._paginator.add_line(ending_note)
        return self._paginator.pages
Ejemplo n.º 3
0
    def format(self):
        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return cog + ':' if cog is not None else '\u200bNo Category:'

        ## Initial setup
        max_width = self.max_name_size
        self._paginator = Paginator()
        phrase_groups = self.context.bot.get_cog("Phrases").phrase_groups

        ## Handle help for subcommands (ex. \help say, \help random, etc)
        if isinstance(self.command, Command):
            command_str = self.command.__str__()
            if (command_str in phrase_groups):
                self.dump_header_boilerplate()
                self.dump_commands()
                self.dump_phrase_group(phrase_groups[command_str], max_width)
                self.dump_phrase_categories(phrase_groups, max_width)
                self.dump_footer_boilerplate()
                return self._paginator.pages

            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(signature, empty=True)

            # <long doc> section
            help_section = self.command.help
            if help_section:
                if (len(help_section) > self._paginator.max_size):
                    for line in help_section.splitlines():
                        self._paginator.add_line(line)
                else:
                    self._paginator.add_line(help_section, empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        self.dump_header_boilerplate()

        ## Dump the non-phrase commands
        self.dump_commands()

        ## Dump the base phrase commands
        phrases_group = phrase_groups["phrases"]
        if (phrases_group):
            self.dump_phrase_group(phrases_group)

        ## Dump the names of the additional phrases. Don't print their commands because that's too much info.
        ## This is a help interface, not a CVS receipt
        self.dump_phrase_categories(phrase_groups)

        self.dump_footer_boilerplate()

        return self._paginator.pages
Ejemplo n.º 4
0
    def format(self):
        internationalization.set_language(self.context.message)
        self._paginator = Paginator()

        # we need a padding of ~80 or so

        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(_(description), empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(_(signature), empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(_(self.command.help), empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        self._paginator.add_line(_("Commands:"))
        self._custom_add_subcommands_to_page(max_width,
                                             self.filter_command_list())

        # add the ending note
        self._paginator.add_line()
        ending_note = self._custom_get_ending_note()
        self._paginator.add_line(ending_note)
        return self._paginator.pages
Ejemplo n.º 5
0
def paginate(text, maxlen=1990):
    paginator = Paginator(prefix='```py', max_size=maxlen + 10)
    if type(text) == list:
        data = to_list_of_str(text)
    elif type(text) == dict:
        data = to_list_of_str(text)
    else:
        data = str(text).split('\n')
    for line in data:
        if len(line) > maxlen:
            n = maxlen
            for l in [line[i:i + n] for i in range(0, len(line), n)]:
                paginator.add_line(l)
        else:
            paginator.add_line(line)
    return paginator.pages
Ejemplo n.º 6
0
    def format(self):
        self._paginator = Paginator()
        gid = self.context.guild.id

        if self.is_bot():
            self._paginator.add_line(inspect.cleandoc(
                getlang(gid, "bot.description").format(cfg.name)),
                                     empty=True)
        elif self.is_cog():
            # self._paginator.add_line(getlang(gid, ))
            pass  # TODO: HELP!!
        elif isinstance(self.command, Command):
            self._paginator.add_line(getlang(
                gid, "brief." + self.command.qualified_name.replace(' ', '.')),
                                     empty=True)

            # TODO: Translate signatures
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(signature, empty=True)

            # <long doc> section
            long_doc = getlang(
                gid, "help." + self.command.qualified_name.replace(' ', '.'))
            if long_doc:
                self._paginator.add_line(inspect.cleandoc(long_doc),
                                         empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return cog + ':' if cog is not None else '\u200bNo Category:'

        filtered = yield from self.filter_command_list()
        if self.is_bot():
            data = sorted(filtered, key=category)
            for category, commands in itertools.groupby(data, key=category):
                # there simply is no prettier way of doing this.
                commands = sorted(commands)
                if len(commands) > 0:
                    self._paginator.add_line(category)

                self.add_localized_subcommands_to_page(max_width, commands)
        else:
            filtered = sorted(filtered)
            if filtered:
                self._paginator.add_line('Commands:')
                self.add_localized_subcommands_to_page(max_width, filtered)

        # add the ending note
        self._paginator.add_line()
        ending_note = self.get_localized_ending_note()
        self._paginator.add_line(ending_note)

        return self._paginator.pages
Ejemplo n.º 7
0
    async def format(self):
        """Handles the actual behaviour involved with formatting.

        To change the behaviour, this method should be overridden.

        Returns
        --------
        list
            A paginated output of the help command.
        """
        self._paginator = Paginator()

        # we need a padding of ~80 or so

        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(description, empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(signature, empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(self.command.help, empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return cog + ':' if cog is not None else '\u200bDefault:'

        filtered = await self.filter_command_list()
        if self.is_bot():
            data = sorted(filtered, key=category)
            for category, commands in itertools.groupby(data, key=category):
                # there simply is no prettier way of doing this.
                commands = sorted(commands)
                if len(commands) > 0:
                    self._paginator.add_line(category)

                self._add_subcommands_to_page(max_width, commands)
        else:
            filtered = sorted(filtered)
            if filtered:
                self._paginator.add_line('Commands:')
                self._add_subcommands_to_page(max_width, filtered)

        try:
            with open('node_help.txt') as f:
                node_help = f.read().strip()
                node_help = node_help.split('\n')
                node_help_mod = []
                # Split node_help into public part and mod only part
                # the line to split at should begin with ---
                for i in range(len(node_help)):
                    if node_help[i].startswith('---'):
                        node_help_mod = node_help[i + 1:]
                        node_help = node_help[0:i]
                        break
                # Print public part
                for line in node_help:
                    if ':' in line:
                        c, d = line.split(':')
                        num_spaces = max_width - len(c) + 1
                        self._paginator.add_line('  ' + c + ' ' * num_spaces +
                                                 d)
                    else:
                        self._paginator.add_line(line + ':')
                # if helpall was called - also print the mod only part
                if self.show_hidden:
                    for line in node_help_mod:
                        if ':' in line:
                            c, d = line.split(':')
                            num_spaces = max_width - len(c) + 1
                            self._paginator.add_line('  ' + c +
                                                     ' ' * num_spaces + d)
                        else:
                            self._paginator.add_line(line + ':')

        except FileNotFoundError as e:
            print('node_help.txt not found', e)
        return self._paginator.pages
Ejemplo n.º 8
0
class myHelpFormatter(HelpFormatter):
    # Special Help Formatter that can take a showHidden
    # Parameter to include include hidden commands
    # Mostly copied from discord.py/discord/ext/commands/formatter.py
    def __init__(self, showHidden=False, is_sub=False):
        super().__init__()
        self.show_hidden = showHidden
        self.is_sub = is_sub

    async def format(self):
        """Handles the actual behaviour involved with formatting.

        To change the behaviour, this method should be overridden.

        Returns
        --------
        list
            A paginated output of the help command.
        """
        self._paginator = Paginator()

        # we need a padding of ~80 or so

        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(description, empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(signature, empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(self.command.help, empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return cog + ':' if cog is not None else '\u200bDefault:'

        filtered = await self.filter_command_list()
        if self.is_bot():
            data = sorted(filtered, key=category)
            for category, commands in itertools.groupby(data, key=category):
                # there simply is no prettier way of doing this.
                commands = sorted(commands)
                if len(commands) > 0:
                    self._paginator.add_line(category)

                self._add_subcommands_to_page(max_width, commands)
        else:
            filtered = sorted(filtered)
            if filtered:
                self._paginator.add_line('Commands:')
                self._add_subcommands_to_page(max_width, filtered)
        return self._paginator.pages
Ejemplo n.º 9
0
class HawkingHelpFormatter(HelpFormatter):
    @property
    def max_name_size(self):
        """
        int : Returns the largest name length of the bot's commands.
        """
        try:
            commands = self.context.bot.commands
            if commands:
                return max(
                    map(
                        lambda c: len(c.name)
                        if self.show_hidden or not c.hidden else 0,
                        commands.values()))
            return 0
        except AttributeError:
            return len(self.command.name)

    def dump_header_boilerplate(self):
        """
        Adds the header boilerplate text (Description, Version, How to activate) to the paginator
        """
        self._paginator.add_line(CONFIG_OPTIONS.get("description"),
                                 empty=False)

        ## Append the version info into the help screen
        version_note = "Hawking version: {}".format(
            CONFIG_OPTIONS.get("version", "Beta"))
        self._paginator.add_line(version_note, empty=True)

        ## Append (additional) activation note
        activation_note = "Activate with the '{0}' character (ex. '{0}help')".format(
            self.clean_prefix)
        self._paginator.add_line(activation_note, empty=True)

    def dump_footer_boilerplate(self):
        """
        Adds the footer boilerplate text (Using the help interface) to the paginator
        """
        # Ending note logic from HelpFormatter.format
        command_name = self.context.invoked_with
        ending_note = "Type '{0}{1}' command for more info on a command.\n" \
                        "You can also type '{0}{1}' category for more info on a category.".format(
                            self.clean_prefix, command_name)
        self._paginator.add_line(ending_note)

    def dump_commands(self):
        """
        Adds information about the bot's available commands (unrelated to the phrase commands) to the paginator
        """
        self._paginator.add_line("Commands:")
        for name, command in sorted(self.context.bot.commands.items(),
                                    key=lambda tup: tup[1].module.__name__):
            module_name = command.module.__name__
            if (module_name != "phrases" and not command.hidden):
                entry = '  {0:<{width}} {1}'.format(name,
                                                    command.short_doc,
                                                    width=self.max_name_size)
                self._paginator.add_line(self.shorten(entry))
        self._paginator.add_line()

    def dump_phrase_group(self, phrase_group, width=None):
        """
        Adds information about the supplied phrase group (Group name, tabbed list of phrase commands) to the paginator
        """
        if (not width):
            width = self.max_name_size

        self._paginator.add_line(phrase_group.name + ":")
        for name, phrase in sorted(phrase_group.phrases.items(),
                                   key=lambda tup: tup[0]):
            entry = '  {0:<{width}} {1}'.format(name,
                                                phrase.kwargs.get("help"),
                                                width=width)
            self._paginator.add_line(self.shorten(entry))
        self._paginator.add_line()

    def dump_phrase_categories(self, phrase_groups, width=None):
        """
        Adds information about the bot's phrase categories, that the user can drill down into with the help interface,
        to the paginator
        """
        if (not width):
            width = self.max_name_size

        header_raw = "Phrase Categories (Use '{}help category' to see the category's extra commands!):"
        self._paginator.add_line(header_raw.format(self.clean_prefix))
        for name, group in sorted(phrase_groups.items(),
                                  key=lambda tup: tup[0]):
            ## Don't insert empty groups
            if (len(group.phrases) > 0):
                entry = '  {0:<{width}} {1}'.format(group.key,
                                                    group.description,
                                                    width=width)
                self._paginator.add_line(self.shorten(entry))
        self._paginator.add_line()

    ## Override default formatting method
    def format(self):
        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return cog + ':' if cog is not None else '\u200bNo Category:'

        ## Initial setup
        max_width = self.max_name_size
        self._paginator = Paginator()
        phrase_groups = self.context.bot.get_cog("Phrases").phrase_groups

        ## Handle help for subcommands (ex. \help say, \help random, etc)
        if isinstance(self.command, Command):
            command_str = self.command.__str__()
            if (command_str in phrase_groups):
                self.dump_header_boilerplate()
                self.dump_commands()
                self.dump_phrase_group(phrase_groups[command_str], max_width)
                self.dump_phrase_categories(phrase_groups, max_width)
                self.dump_footer_boilerplate()
                return self._paginator.pages

            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(signature, empty=True)

            # <long doc> section
            help_section = self.command.help
            if help_section:
                if (len(help_section) > self._paginator.max_size):
                    for line in help_section.splitlines():
                        self._paginator.add_line(line)
                else:
                    self._paginator.add_line(help_section, empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        self.dump_header_boilerplate()

        ## Dump the non-phrase commands
        self.dump_commands()

        ## Dump the base phrase commands
        phrases_group = phrase_groups["phrases"]
        if (phrases_group):
            self.dump_phrase_group(phrases_group)

        ## Dump the names of the additional phrases. Don't print their commands because that's too much info.
        ## This is a help interface, not a CVS receipt
        self.dump_phrase_categories(phrase_groups)

        self.dump_footer_boilerplate()

        return self._paginator.pages
Ejemplo n.º 10
0
    def format(self):
        description_paginator = Paginator(max_size=2048)
        max_width = self.max_name_size
        if self.is_bot():

            def category(tup):
                cog = tup[1].cog_name
                # we insert the zero width space there to give it approximate last place sorting position
                return cog if cog is not None else "\u200bNo Category"

            ## data = sorted(self.filter_command_list(), key = category)
            data = sorted(self.filter_command_list(),
                          key=lambda c: category(c).lower())
            embeds = [
                discord.Embed(title="My Commands", color=clients.bot_color)
            ]
            for category, commands in itertools.groupby(data, key=category):
                commands = sorted(commands, key=lambda c: c[0])
                if len(commands) > 0:
                    field_paginator = Paginator(max_size=1024)
                    self._add_subcommands_to_page(max_width, commands,
                                                  field_paginator)
                    # Embed Limit
                    total_paginator_characters = len(
                        field_paginator.pages) * len(category + " (coninued)")
                    for page in field_paginator.pages:
                        total_paginator_characters += len(page)
                    if utilities.embed_total_characters(
                            embeds[-1]) + total_paginator_characters > 4000:
                        embeds.append(discord.Embed(color=clients.bot_color))
                    #
                    if len(embeds[-1].fields) <= 25 - len(
                            field_paginator.pages):
                        embeds[-1].add_field(name=category,
                                             value=field_paginator.pages[0],
                                             inline=False)
                    else:
                        embeds.append(
                            discord.Embed(color=clients.bot_color).add_field(
                                name=category,
                                value=field_paginator.pages[0],
                                inline=False))
                    for page in field_paginator.pages[1:]:
                        embeds[-1].add_field(
                            name="{} (continued)".format(category),
                            value=page,
                            inline=False)
            return embeds
        elif isinstance(self.command, Command):
            # <signature portion>
            title = self.get_command_signature()
            # <long doc> section
            if self.command.help:
                description_paginator.add_line(self.command.help, empty=True)
            # end it here if it's just a regular command
            if not self.has_subcommands() or not list(
                    self.filter_command_list()):
                description_paginator.close_page()
                if not self.command.help:
                    return [
                        discord.Embed(title=title,
                                      description=self.command.description,
                                      color=clients.bot_color)
                    ]
                elif len(self.command.help) <= 2048:
                    description = clients.code_block.format(
                        self.command.help
                    ) if "  " in self.command.help else self.command.help
                    description += "\n" + self.command.description
                    return [
                        discord.Embed(title=title,
                                      description=description,
                                      color=clients.bot_color)
                    ]
                return self.embeds(title, description_paginator)
            subcommands = sorted(self.filter_command_list(),
                                 key=lambda c: c[0])
            subcommands_lines = self._subcommands_lines(max_width, subcommands)
            if (not self.command.help or len(self.command.help) <= 2048
                ) and len('\n'.join(subcommands_lines)) <= 1016:
                # 1024 - 4 * 2
                embed = discord.Embed(color=clients.bot_color)
                value = "{}\n".format(description_paginator.pages[0]
                                      ) if description_paginator.pages else ""
                value += self.command.description
                if not value:
                    embed.title = title
                else:
                    embed.add_field(name=title, value=value, inline=False)
                embed.add_field(name="Subcommands for {}".format(self.command),
                                value=clients.code_block.format(
                                    '\n'.join(subcommands_lines)),
                                inline=False)
                return [embed]
            description_paginator.add_line("Subcommands for {}:".format(
                self.command))
            self._add_subcommands_to_page(max_width, subcommands,
                                          description_paginator)
        else:  # cog
            description = inspect.getdoc(self.command)
            if description:
                # <description> portion
                description_paginator.add_line(description, empty=True)
            title = "{} Commands".format(type(self.command).__name__)
            subcommands = sorted(self.filter_command_list(),
                                 key=lambda c: c[0])
            self._add_subcommands_to_page(max_width, subcommands,
                                          description_paginator)
        return self.embeds(title, description_paginator)
Ejemplo n.º 11
0
class FormatterDeprecated(HelpFormatter):
    Generic = 0
    Cog = 1
    Command = 2

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def format_help_for(self, context, command_or_bot, is_owner=False):
        self.context = context
        self.command = command_or_bot
        return self.format(is_owner=is_owner)

    def format(self, is_owner=False, generic=False):
        """Handles the actual behaviour involved with formatting.

        To change the behaviour, this method should be overridden.

        Returns
        --------
        list
            A paginated output of the help command.
        """
        if generic:
            self._paginator = Paginator(prefix='```Markdown\n')
        else:
            self._paginator = Paginator(prefix='', suffix='')

        # we need a padding of ~80 or so

        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(description, empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            if self.command.owner_only:
                signature = 'This command is owner only\n' + signature

            self._paginator.add_line(signature, empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(self.command.help, empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        def category(tup):
            cog = tup[1].cog_name
            # we insert the zero width space there to give it approximate
            # last place sorting position.
            return cog + ':' if cog is not None else '\u200bNo Category:'

        if self.is_bot():
            data = sorted(self.filter_command_list(), key=category)
            for category, commands in itertools.groupby(data, key=category):
                # there simply is no prettier way of doing this.
                commands = list(commands)
                if len(commands) > 0:
                    self._paginator.add_line('#' + category)

                self._add_subcommands_to_page(max_width,
                                              commands,
                                              is_owner=is_owner)
        else:
            self._paginator.add_line('Commands:')
            self._add_subcommands_to_page(max_width,
                                          self.filter_command_list(),
                                          is_owner=is_owner)

        # add the ending note
        self._paginator.add_line()
        ending_note = self.get_ending_note()
        self._paginator.add_line(ending_note)
        return self._paginator.pages

    def _add_subcommands_to_page(self, max_width, commands, is_owner=False):
        for name, command in commands:
            if name in command.aliases:
                # skip aliases
                continue

            if command.owner_only and not is_owner:
                continue

            entry = '  {0:<{width}} {1}'.format(name,
                                                command.short_doc,
                                                width=max_width)
            shortened = self.shorten(entry)
            self._paginator.add_line(shortened)
Ejemplo n.º 12
0
class CustomHelpFormatter(HelpFormatter):
    def _custom_add_subcommands_to_page(self, max_width, commands):
        for name, command in commands:
            if name in command.aliases:
                # skip aliases
                continue

            entry = '  {0:<{width}} {1}'.format(_(name),
                                                _(command.short_doc),
                                                width=max_width)
            shortened = self.shorten(entry)
            self._paginator.add_line(shortened)

    def _custom_get_ending_note(self):
        command_name = self.context.invoked_with
        return _("Type {0}{1} command for more info on a command.").format(
            self.clean_prefix, command_name)

    def format(self):
        internationalization.set_language(self.context.message)
        self._paginator = Paginator()

        # we need a padding of ~80 or so

        description = self.command.description if not self.is_cog(
        ) else inspect.getdoc(self.command)

        if description:
            # <description> portion
            self._paginator.add_line(_(description), empty=True)

        if isinstance(self.command, Command):
            # <signature portion>
            signature = self.get_command_signature()
            self._paginator.add_line(_(signature), empty=True)

            # <long doc> section
            if self.command.help:
                self._paginator.add_line(_(self.command.help), empty=True)

            # end it here if it's just a regular command
            if not self.has_subcommands():
                self._paginator.close_page()
                return self._paginator.pages

        max_width = self.max_name_size

        self._paginator.add_line(_("Commands:"))
        self._custom_add_subcommands_to_page(max_width,
                                             self.filter_command_list())

        # add the ending note
        self._paginator.add_line()
        ending_note = self._custom_get_ending_note()
        self._paginator.add_line(ending_note)
        return self._paginator.pages