352
352
def test_option_grammar(self):
354
354
# Option help should be written in sentence form, and have a final
355
# period and be all on a single line, because the display code will
357
option_re = re.compile(r'^[A-Z][^\n]+\.$')
355
# period with an optional bracketed suffix. All the text should be on
356
# one line, because the display code will wrap it.
357
option_re = re.compile(r'^[A-Z][^\n]+\.(?: \([^\n]+\))?$')
358
358
for scope, opt in self.get_builtin_command_options():
360
msgs.append('%-16s %-16s %s' %
361
((scope or 'GLOBAL'), opt.name, 'NO HELP'))
362
elif not option_re.match(opt.help):
363
msgs.append('%-16s %-16s %s' %
364
((scope or 'GLOBAL'), opt.name, opt.help))
359
for name, _, _, helptxt in opt.iter_switches():
361
name = "/".join([opt.name, name])
363
msgs.append('%-16s %-16s %s' %
364
((scope or 'GLOBAL'), name, 'NO HELP'))
365
elif not option_re.match(helptxt):
366
if name.startswith("format/"):
367
# Don't complain about the odd format registry help
369
msgs.append('%-16s %-16s %s' %
370
((scope or 'GLOBAL'), name, helptxt))
366
372
self.fail("The following options don't match the style guide:\n"
367
373
+ '\n'.join(msgs))