click-contrib / sphinx-click

A Sphinx plugin to automatically document click-based applications
MIT License
212 stars 57 forks source link

Missing documentation for Custom Multi Commands #23

Closed omercnet closed 6 years ago

omercnet commented 6 years ago

When using Custom Multi Commands sphinx-click doesn't document the subcommands because multicommand.commands is empty

A quick solution on click's side would be to manually populate the commands attribute by loading all the commands but if you're trying to lazy load on purpose you may cry about performance issues.

class MyGroup(click.MultiCommand):
    """Dynamic group loader class."""

    folder = None

    def __init__(self, **kwargs):
        click.MultiCommand.__init__(self, **kwargs)
        self.commands = self._get_commands()

    def _get_commands(self):
        commands = {}
        for command in self.list_commands(self):
            commands[command] = self.get_command(self, command)

        return commands

I also patched a partial fix in https://github.com/omercnet/sphinx-click/commit/749761828ba2c22d94bb6128e35e7e2955c71786 but it doesn't show the MultiCommand name in the docs (returns None), if anyone is willing to help finish it off that would be great :)

omercnet commented 6 years ago

The issue was that I didn't assign the name property to the custom command, opened #25