本文整理汇总了Python中coalib.misc.BuildManPage.ManPageFormatter类的典型用法代码示例。如果您正苦于以下问题:Python ManPageFormatter类的具体用法?Python ManPageFormatter怎么用?Python ManPageFormatter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ManPageFormatter类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mk_footer
def test_mk_footer(self):
uut = ManPageFormatter(app_name, ext_sections=sections)
self.assertEqual(uut._mk_footer(),
".SH {0}\n"
" {1}".format(section_name.upper(), section_text))
uut = ManPageFormatter(app_name, ext_sections=None)
self.assertEqual(uut._mk_footer(), "")
示例2: test_formatter
def test_formatter(self):
parser = test_arg_parser(ManPageFormatter)
self.assertEqual(
parser.format_help(),
"usage: {0} [-h] [-a A] arg1\n\n{1}\n\n"
"positional arguments:\n"
" arg1\n\n"
"optional arguments:\n"
" \\fB-h\\fR, \\fB--help\\fR\n"
" show this help message and exit\n"
" \\fB-a\\fR \\fIA\\fR\n"
.format(app_name, app_description))
parser = ManPageFormatter(app_name,
parser=argparse.ArgumentParser(prog=app_name))
today = datetime.date.today().strftime('%Y\\-%m\\-%d')
self.assertEqual(parser.format_man_page(),
".TH {0} 1 {1}\n"
".SH NAME\n"
"{0}\n"
".SH SYNOPSIS\n"
" \\fBname\\fR [-h]\n\n\n"
".SH OPTIONS\n"
" -h, --help show this help message and exit\n"
.format(app_name, today))
示例3: test_format_functions
def test_format_functions(self):
uut = ManPageFormatter(app_name)
self.assertEqual(ManPageFormatter._markup("a-b"), "a\\-b")
self.assertEqual(ManPageFormatter._underline("test"), "\\fItest\\fR")
self.assertEqual(ManPageFormatter._bold("test"), "\\fBtest\\fR")
self.assertEqual(ManPageFormatter._bold("\\fBtest"), "\\fBtest\\fR")
self.assertEqual(ManPageFormatter._bold("test\\fR"), "\\fBtest\\fR")
示例4: test_mk_options
def test_mk_options(self):
uut = ManPageFormatter(app_name, parser=test_arg_parser())
self.assertEqual(uut._mk_options(),
".SH OPTIONS\n"
" arg1\n\n"
" -h, --help show this help message and exit\n"
" -a A\n")
示例5: test_mk_description
def test_mk_description(self):
uut = ManPageFormatter(app_name,
parser=test_arg_parser())
self.assertEqual(uut._mk_description(), "")
uut = ManPageFormatter(app_name,
parser=test_arg_parser(),
long_desc=app_long_description)
self.assertEqual(uut._mk_description(),
".SH DESCRIPTION\n{}\n".format(app_long_description))
示例6: test_mk_synopsis
def test_mk_synopsis(self):
uut = ManPageFormatter(app_name, parser=test_arg_parser())
self.assertEqual(
uut._mk_synopsis(),
".SH SYNOPSIS\n \\fB{}\\fR [-h] [-a A] arg1\n\n\n".format(app_name))
示例7: test_mk_name
def test_mk_name(self):
uut = ManPageFormatter(app_name, parser=test_arg_parser())
self.assertEqual(uut._mk_name(),
".SH NAME\n{}\n".format(app_name))
示例8: test_mk_title
def test_mk_title(self):
uut = ManPageFormatter(app_name, parser=test_arg_parser())
today = datetime.date.today().strftime('%Y\\-%m\\-%d')
self.assertEqual(uut._mk_title(),
'.TH {0} {1} {2}\n'.format(app_name, 1, today))
示例9: test_format_functions
def test_format_functions(self):
self.assertEqual(ManPageFormatter._markup('a-b'), 'a\\-b')
self.assertEqual(ManPageFormatter._underline('test'), '\\fItest\\fR')
self.assertEqual(ManPageFormatter._bold('test'), '\\fBtest\\fR')
self.assertEqual(ManPageFormatter._bold('\\fBtest'), '\\fBtest\\fR')
self.assertEqual(ManPageFormatter._bold('test\\fR'), '\\fBtest\\fR')