From cddf7e09869a7e7b00dd7913f8562c3d758acfb2 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 27 Jan 2013 12:58:52 -0800 Subject: [PATCH] Clean up man page parser output a bit --- share/tools/create_manpage_completions.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/share/tools/create_manpage_completions.py b/share/tools/create_manpage_completions.py index 319323da8..5a1b5610b 100755 --- a/share/tools/create_manpage_completions.py +++ b/share/tools/create_manpage_completions.py @@ -138,7 +138,15 @@ def builtcommand(options, description): truncation_suffix = u'… [See Man Page]' # Try to include as many whole sentences as will fit - sentences = description.split('.') + # Clean up some probably bogus escapes in the process + clean_desc = description.replace("\\'", "'").replace("\\.", ".") + sentences = clean_desc.split('.') + + # Clean up "sentences" that are just whitespace + # But don't let it be empty + sentences = [x for x in sentences if x.strip()] + if not sentences: sentences = [''] + truncated_description = sentences[0] + '.' for line in sentences[1:]: if not line: continue