| 2784 | return formatter.format_help() |
| 2785 | |
| 2786 | def format_help(self, formatter=None): |
| 2787 | if formatter is None: |
| 2788 | formatter = self._get_formatter() |
| 2789 | |
| 2790 | # usage |
| 2791 | formatter.add_usage(self.usage, self._actions, |
| 2792 | self._mutually_exclusive_groups) |
| 2793 | |
| 2794 | # description |
| 2795 | formatter.add_text(self.description) |
| 2796 | |
| 2797 | # positionals, optionals and user-defined groups |
| 2798 | for action_group in self._action_groups: |
| 2799 | formatter.start_section(action_group.title) |
| 2800 | formatter.add_text(action_group.description) |
| 2801 | formatter.add_arguments(action_group._group_actions) |
| 2802 | formatter.end_section() |
| 2803 | |
| 2804 | # epilog |
| 2805 | formatter.add_text(self.epilog) |
| 2806 | |
| 2807 | # determine help from format above |
| 2808 | return formatter.format_help() |
| 2809 | |
| 2810 | def _get_formatter(self, file=None): |
| 2811 | formatter = self.formatter_class(prog=self.prog) |