mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Handle some more escapes in de-groffing man pages
Fixes https://github.com/fish-shell/fish-shell/issues/10
This commit is contained in:
parent
be3fff9282
commit
c7bf1aa222
1 changed files with 15 additions and 4 deletions
|
@ -509,10 +509,15 @@ class TypeDarwinManParser(ManParser):
|
||||||
line = line[3:]
|
line = line[3:]
|
||||||
return line
|
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):
|
def is_option(self, line):
|
||||||
return line.startswith('.It Fl')
|
return line.startswith('.It Fl')
|
||||||
|
|
||||||
|
|
||||||
def parseManPage(self, manpage):
|
def parseManPage(self, manpage):
|
||||||
got_something = False
|
got_something = False
|
||||||
lines = manpage.splitlines()
|
lines = manpage.splitlines()
|
||||||
|
@ -528,10 +533,15 @@ class TypeDarwinManParser(ManParser):
|
||||||
if not lines:
|
if not lines:
|
||||||
continue
|
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
|
# Extract the name
|
||||||
name = self.trim_groff(lines.pop(0)).strip()
|
name = line.split(None, 2)[0]
|
||||||
if not name: continue
|
|
||||||
name = name.split(None, 2)[0]
|
|
||||||
|
|
||||||
# Extract the description
|
# Extract the description
|
||||||
desc = ''
|
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
|
# 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(1, "# Autogenerated from man pages")
|
||||||
|
built_command_output.insert(2, "# using " + parser_name)
|
||||||
for line in built_command_output:
|
for line in built_command_output:
|
||||||
output_file.write(line)
|
output_file.write(line)
|
||||||
output_file.write('\n')
|
output_file.write('\n')
|
||||||
|
|
Loading…
Reference in a new issue