help2man

Provide __version__ for importlib.metadata.version().

help2man.get_output(f: Callable, args: tuple = (), no_discard_stderr: bool = False) str[source]

Get stdout and stderr of a function.

Parameters:
  • f (Callable) –

  • args (tuple) –

  • no_discard_stderr (bool) –

Return type:

str

help2man.help2man(helpstr: str, versionstr: str, name: str = 'Name', section: str = '1', manual: str = 'User Commands', source: str = '', info_page: str = '', template: str = '.\\" DO NOT MODIFY THIS FILE!  It was generated by help2man {{ help2man_version }}.\n.TH {{ prog.upper() }} "{{ section }}" "{{ date }}" "{%- if source -%}{{ source }} {%- endif -%}{{ prog }} {{ version }}" "{{ manual }}"\n.SH {{ name.upper() }}\n{{ prog }} \\- {{ description }}\n.SH SYNOPSIS\n\\&{{ synopsis }}\n{% if description -%}\n.SH DESCRIPTION\n\\&{{ description }}\n{% endif -%}\n{% for s in sections -%}\n.SH {{ s.title.upper() }}\n{% for c in s.contents -%}\n{% if c.name -%}\n.TP\n\\&{{ c.name }}\n\\&{{ c.description }}\n{% else -%}\n.IP\n\\&{{ c.description }}\n{% endif -%}\n{% endfor -%}\n{% endfor -%}\n{% if author %}\n.SH AUTHOR\nWritten by {{ author }}\n{% endif %}\n{% if bug %}\n.SH "REPORTING BUGS"\nReport bugs to {{ bug }}\n{% endif %}\n{% if copyright %}\n.SH COPYRIGHT\nCopyright \\(co {{ copyright }}\n{% endif %}\n{% if info_page -%}\n.SH "SEE ALSO"\nThe full documentation for\n.B {{ prog }}\nis maintained as a Texinfo manual.  If the\n.B info\nand\n.B {{ prog }}\nprograms are properly installed at your site, the command\n.IP\n.B info {{ info_page }}\n.PP\nshould give you access to the complete manual.\n{%- endif -%}\n') str[source]

Convert help string and version string to man.

Parameters:
  • helpstr (str) –

  • versionstr (str) –

  • name (str) –

  • section (str) –

  • manual (str) –

  • source (str) –

  • info_page (str) –

  • template (str) –

Return type:

str

help2man.parser2man(parser: ArgumentParser, name: str = 'Name', section: str = '1', manual: str = 'User Commands', source: str = '', info_page: str = '', template: str = '.\\" DO NOT MODIFY THIS FILE!  It was generated by help2man {{ help2man_version }}.\n.TH {{ prog.upper() }} "{{ section }}" "{{ date }}" "{%- if source -%}{{ source }} {%- endif -%}{{ prog }} {{ version }}" "{{ manual }}"\n.SH {{ name.upper() }}\n{{ prog }} \\- {{ description }}\n.SH SYNOPSIS\n\\&{{ synopsis }}\n{% if description -%}\n.SH DESCRIPTION\n\\&{{ description }}\n{% endif -%}\n{% for s in sections -%}\n.SH {{ s.title.upper() }}\n{% for c in s.contents -%}\n{% if c.name -%}\n.TP\n\\&{{ c.name }}\n\\&{{ c.description }}\n{% else -%}\n.IP\n\\&{{ c.description }}\n{% endif -%}\n{% endfor -%}\n{% endfor -%}\n{% if author %}\n.SH AUTHOR\nWritten by {{ author }}\n{% endif %}\n{% if bug %}\n.SH "REPORTING BUGS"\nReport bugs to {{ bug }}\n{% endif %}\n{% if copyright %}\n.SH COPYRIGHT\nCopyright \\(co {{ copyright }}\n{% endif %}\n{% if info_page -%}\n.SH "SEE ALSO"\nThe full documentation for\n.B {{ prog }}\nis maintained as a Texinfo manual.  If the\n.B info\nand\n.B {{ prog }}\nprograms are properly installed at your site, the command\n.IP\n.B info {{ info_page }}\n.PP\nshould give you access to the complete manual.\n{%- endif -%}\n') str[source]

Convert a parser to man.

Parameters:
  • parser (ArgumentParser) –

  • name (str) –

  • section (str) –

  • manual (str) –

  • source (str) –

  • info_page (str) –

  • template (str) –

Return type:

str

help2man.parser2strings(parser: ArgumentParser, no_discard_stderr: bool = False) tuple[str, str][source]

Convert a parser to help string and version string.

Parameters:
  • parser (ArgumentParser) –

  • no_discard_stderr (bool) –

Return type:

tuple[str, str]

This module can be called by python -m.

help2man.__main__.get_parser() ArgumentParser[source]

Get a parser for unit test and help2man. Provide shell completions.

Return type:

ArgumentParser

help2man.__main__.main() None | NoReturn[source]

python -m translate_shell call this function. Parse arguments is before init configuration to provide --config.

Return type:

None | NoReturn