Skip to content
Myr

Merge pull request #1327 from thecav/document-format-methods

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add a docstring to Command.get_usage to clarify how to retrieve usage

authored by David Lord · committed by GitHub · parents 017ea84, 6fda3d7 · Browse files · 1 file+14 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+14 added−4 removed

  • other:+14 added−4 removed

1 file+14 added−4 removed

modified:click/core.py+14 added-4 removed
826 unmodified lines
827 self.hidden = hidden828 self.deprecated = deprecated829830 def get_usage(self, ctx):831 """Formats the usage line into a string and returns it.832833 Calls :meth:`format_usage` internally.834 """835 formatter = ctx.make_formatter()836 self.format_usage(ctx, formatter)837 return formatter.getvalue().rstrip('\n')838
4 unmodified lines
843 rv = rv + [help_option]844 return rv845846 def format_usage(self, ctx, formatter):843 """Writes the usage line into the formatter."""847 """Writes the usage line into the formatter.848849 This is a low-level method called by :meth:`get_usage`.850 """851 pieces = self.collect_usage_pieces(ctx)852 formatter.write_usage(ctx.command_path, ' '.join(pieces))853854 def collect_usage_pieces(self, ctx):
35 unmodified lines
890 param.add_to_parser(parser, ctx)891 return parser892893 def get_help(self, ctx):887 """Formats the help into a string and returns it. This creates a888 formatter and will call into the following formatting methods:894 """Formats the help into a string and returns it.895896 Calls :meth:`format_help` internally.897 """898 formatter = ctx.make_formatter()899 self.format_help(ctx, formatter)900 return formatter.getvalue().rstrip('\n')
4 unmodified lines
905906 def format_help(self, ctx, formatter):907 """Writes the help into the formatter if it exists.908901 This calls into the following methods:909 This is a low-level method called by :meth:`get_help`.910911 This calls the following methods:912913 - :meth:`format_usage`914 - :meth:`format_help_text`915 - :meth:`format_options`916 - :meth:`format_epilog`
967 unmodified lines