def format_help_text(self, ctx: click.Context, formatter: click.HelpFormatter) -> None: """Writes the help text to the formatter if it exists.""" help = self.help # type: ignore deprecated = self.deprecated # type: ignore if help: help_text, *examples = split_examples(help) if help_text: formatter.write_paragraph() with formatter.indentation(): if deprecated: help_text += DEPRECATED_HELP_NOTICE formatter.write_text(help_text) examples = [example.strip() for example in examples] for example in examples: format_example(example, formatter) elif deprecated: formatter.write_paragraph() with formatter.indentation(): formatter.write_text(DEPRECATED_HELP_NOTICE)
def format_help_text(text: str, formatter: click.HelpFormatter): text = inspect.cleandoc(text).partition("\f")[0] formatter.write_paragraph() with formatter.indentation(): formatter.write_text(text)