Handle some more escapes in de-groffing man pages

Fixes https://github.com/fish-shell/fish-shell/issues/10
This commit is contained in:
ridiculousfish 2012-10-17 18:22:57 -07:00
parent be3fff9282
commit c7bf1aa222

View File

@ -509,10 +509,15 @@ class TypeDarwinManParser(ManParser):
line = line[3:]
return line
# Replace some groff escapes. There's a lot we don't bother to handle.
def groff_replace_escapes(self, line):
line = line.replace('\\ ', ' ')
line = line.replace('\& ', '')
return line
def is_option(self, line):
return line.startswith('.It Fl')
def parseManPage(self, manpage):
got_something = False
lines = manpage.splitlines()
@ -528,10 +533,15 @@ class TypeDarwinManParser(ManParser):
if not lines:
continue
# Get the line and clean it up
line = lines.pop(0)
line = self.groff_replace_escapes(line)
line = self.trim_groff(line)
line = line.strip()
if not line: continue
# Extract the name
name = self.trim_groff(lines.pop(0)).strip()
if not name: continue
name = name.split(None, 2)[0]
name = line.split(None, 2)[0]
# Extract the description
desc = ''
@ -741,6 +751,7 @@ def parse_manpage_at_path(manpage_path, yield_to_dirs, output_directory):
# Output the magic word Autogenerated so we can tell if we can overwrite this
built_command_output.insert(1, "# Autogenerated from man pages")
built_command_output.insert(2, "# using " + parser_name)
for line in built_command_output:
output_file.write(line)
output_file.write('\n')