|
5 | 5 | Command-line entry point for flake8-dunder-all. |
6 | 6 | """ |
7 | 7 | # |
8 | | -# Copyright (c) 2020 Dominic Davis-Foster <dominic@davis-foster.co.uk> |
| 8 | +# Copyright (c) 2020-2021 Dominic Davis-Foster <dominic@davis-foster.co.uk> |
9 | 9 | # |
10 | 10 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
11 | 11 | # of this software and associated documentation files (the "Software"), to deal |
|
28 | 28 |
|
29 | 29 | # stdlib |
30 | 30 | import sys |
31 | | -from textwrap import indent |
32 | 31 | from typing import Iterable |
33 | 32 |
|
34 | 33 | # 3rd party |
35 | 34 | import click |
36 | 35 | from consolekit import click_command |
| 36 | +from consolekit.commands import MarkdownHelpCommand |
37 | 37 | from consolekit.options import auto_default_option |
38 | 38 |
|
39 | 39 | # this package |
|
42 | 42 | __all__ = ["main"] |
43 | 43 |
|
44 | 44 |
|
45 | | -class RawHelpCommand(click.Command): |
46 | | - """ |
47 | | - Subclass of :class:`click.Command` which leaves the help text unformatted. |
48 | | - """ |
49 | | - |
50 | | - def format_help_text(self, ctx, formatter: click.formatting.HelpFormatter): |
51 | | - """ |
52 | | - Writes the help text to the formatter if it exists. |
53 | | - """ |
54 | | - |
55 | | - formatter.write('\n') |
56 | | - formatter.write(indent((self.help or '').replace("* ", " "), " ")) |
57 | | - formatter.write('\n') |
58 | | - |
59 | | - |
60 | 45 | @click.argument("filenames", type=click.STRING, nargs=-1, metavar="FILENAME") |
61 | 46 | @auto_default_option("--quote-type", type=click.STRING, help="The type of quote to use.", show_default=True) |
62 | | -@click_command(cls=RawHelpCommand) |
63 | | -def main(filenames: Iterable[str], quote_type: str = '"') -> int: |
| 47 | +@click_command(cls=MarkdownHelpCommand) |
| 48 | +def main(filenames: Iterable[str], quote_type: str = '"'): |
64 | 49 | """ |
65 | | - Given a list of Python source files, check each file defines '__all__'. |
| 50 | + Given a list of Python source files, check each file defines ``__all__``. |
66 | 51 |
|
67 | 52 | Exit codes: |
68 | 53 |
|
69 | | - * 0: The file already contains a '__all__' declaration or has no function or class definitions. |
70 | | - * 1: A '__all__' declaration was added to the file. |
| 54 | + * 0: The file already contains a ``__all__`` declaration or has no function or class definitions. |
| 55 | + * 1: A ``__all__`` declaration was added to the file. |
71 | 56 | * 4: A file could not be parsed due to a syntax error. |
72 | 57 | * 5: Bitwise OR of 1 and 4. |
73 | 58 | """ |
|
0 commit comments