bpo-14102: argparse: Add generate man page by louisom · Pull Request #1169 · python/cpython
|
|
||
| .. method:: ArgumentParser.add_manpage_section(heading, description) | ||
|
|
||
| Adding new section to man page. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Add a new section to the man page. This only has an effect if print_manpage is used."
|
|
||
| Description of parameters: | ||
|
|
||
| * heading: title of the section, it will automatically convert to upper case |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the title of the section, it will be automatically converted to upper case"
| Description of parameters: | ||
|
|
||
| * heading: title of the section, it will automatically convert to upper case | ||
| * description: description about this section |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called content. What is the format of this text? Raw TROFF? This should be documented.
| * heading: title of the section, it will automatically convert to upper case | ||
| * description: description about this section | ||
|
|
||
| Some example usage:: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some
|
|
||
| Some example usage:: | ||
|
|
||
| >>> # Adding Copyright section |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Add a Copyright section"
| # no help; start on same line and add a final newline | ||
| if not action.help: | ||
| tup = self._current_indent, '', action_header | ||
| action_header = '%*s%s' % tup |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argh, why %-formatting here?
action_header = '{:{}}{}'.format('', self._current_indent, action_header)
| # short action name; start on the same line and pad two spaces | ||
| elif len(action_header) <= action_width: | ||
| tup = self._current_indent, '', action_width, action_header | ||
| action_header = '%*s%-*s ' % tup |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action_header = '{:{}}{:>{}}'.format('', self._current_indent, action_header, action_width)
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is better or not, letting this be a longer line.
This code is from argparse itself.
| action_width = help_position - self._current_indent - 2 | ||
| action_header = self._format_action_invocation(action) | ||
|
|
||
| # no help; start on same line and add a final newline |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those comments should be moved under the if, and then the whole if-ifelse-else does not need to be divided by empty lines.
|
|
||
| def format_manpage(self): | ||
| formatter = self._get_formatter() | ||
|
|
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spurious empty line.
| Library | ||
| ------- | ||
|
|
||
| - bpo-14102: argparse now can generate Unix man page. Patch by Louie Lu. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"UNIX man pages"