Skip to content

Commit

Permalink
Fix black issues
Browse files Browse the repository at this point in the history
I should probably automate this.

Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Mar 18, 2021
1 parent 04477b8 commit 934c203
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
10 changes: 3 additions & 7 deletions examples/commandcollections/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name='Principal Commands',
help="Principal commands that are used in ``cli``.\n\n"
"The section name and description are obtained using the name and "
"description of the group passed as sources for |CommandCollection|_."
"description of the group passed as sources for |CommandCollection|_.",
)


Expand All @@ -15,10 +15,7 @@ def cmd1():
print('call cmd 1')


helpers = click.Group(
name='Helper Commands',
help="Helper commands for ``cli``."
)
helpers = click.Group(name='Helper Commands', help="Helper commands for ``cli``.")


@helpers.command()
Expand All @@ -35,6 +32,5 @@ def cmd3(user):


cli = click.CommandCollection(
name='cli', sources=[main, helpers],
help='Some general info on ``cli``.'
name='cli', sources=[main, helpers], help='Some general info on ``cli``.'
)
2 changes: 1 addition & 1 deletion examples/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
setup(
name='sphinx_click_examples',
packages=find_packages('.'),
install_requires=['click']
install_requires=['click'],
)
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
from setuptools import setup

setup(
setup_requires=['pbr>=2.0'], pbr=True,
setup_requires=['pbr>=2.0'],
pbr=True,
)
26 changes: 17 additions & 9 deletions sphinx_click/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,9 @@ def _load_module(self, module_path):
)
return parser

def _generate_nodes(self, name, command, parent, nested, commands=None,
semantic_group=False):
def _generate_nodes(
self, name, command, parent, nested, commands=None, semantic_group=False
):
"""Generate the relevant Sphinx nodes.
Format a `click.Group` or `click.Command`.
Expand Down Expand Up @@ -457,17 +458,24 @@ def _generate_nodes(self, name, command, parent, nested, commands=None,
if nested == NESTED_FULL:
if isinstance(command, click.CommandCollection):
for source in command.sources:
section.extend(self._generate_nodes(
source.name, source, parent=ctx, nested=nested,
semantic_group=True
))
section.extend(
self._generate_nodes(
source.name,
source,
parent=ctx,
nested=nested,
semantic_group=True,
)
)
else:
commands = _filter_commands(ctx, commands)
for command in commands:
parent = ctx if not semantic_group else ctx.parent
section.extend(self._generate_nodes(
command.name, command, parent=parent, nested=nested
))
section.extend(
self._generate_nodes(
command.name, command, parent=parent, nested=nested
)
)

return [section]

Expand Down
3 changes: 1 addition & 2 deletions tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,7 @@ def world():
"""A world command."""

cli = click.CommandCollection(
name='cli', sources=[grp1, grp2],
help='A simple CommandCollection.'
name='cli', sources=[grp1, grp2], help='A simple CommandCollection.'
)
ctx = click.Context(cli, info_name='cli')
output = list(ext._format_command(ctx, nested='full'))
Expand Down

0 comments on commit 934c203

Please sign in to comment.