Make create_manpage_completions not generate empty files

https://github.com/fish-shell/fish-shell/issues/506
This commit is contained in:
ridiculousfish 2013-01-08 14:57:48 -08:00
parent e46cbea251
commit de084b4a0d

View file

@ -132,6 +132,9 @@ def builtcommand(options, description):
# Here's what we'll use to truncate if necessary
max_description_width = 63
if IS_PY3:
truncation_suffix = '… [See Man Page]'
else:
truncation_suffix = u'… [See Man Page]'
# Try to include as many whole sentences as will fit
@ -776,6 +779,9 @@ def parse_manpage_at_path(manpage_path, yield_to_dirs, output_directory):
diagnostic_indent += 1
success = parser.parseManPage(manpage)
diagnostic_indent -= 1
# Make sure empty files aren't reported as success
if not built_command_output:
success = False
if success:
PARSER_INFO.setdefault(parser_name, []).append(CMDNAME)
break
@ -811,6 +817,15 @@ def parse_manpage_at_path(manpage_path, yield_to_dirs, output_directory):
parser_names = ', '.join(p.name() for p in parsersToTry)
#add_diagnostic('%s contains no options or is unparsable' % manpage_path, BRIEF_VERBOSE)
add_diagnostic('%s contains no options or is unparsable (tried parser %s)' % (manpage_path, parser_names), BRIEF_VERBOSE)
# Make sure we delete any old completion
if not WRITE_TO_STDOUT:
fullpath = os.path.join(output_directory, CMDNAME + '.fish')
try:
os.remove(fullpath)
except (OSError, IOError):
# Ignore failure
pass
return success
# Indicates whether the given filename has a presence in one of the yield-to directories
@ -823,28 +838,6 @@ def file_in_yield_directory(filename, yield_to_dirs):
return True
return False
# Indicates whether we want to skip this command because it already had a non-autogenerated completion
def should_skip_man_page(output_path, filename, yield_to_dirs):
# No reason to skip if we're writing to stdout
if WRITE_TO_STDOUT:
return false
# Check all the yield directories
for yield_dir in yield_to_dirs:
test_path = os.path.join(yield_dir, filename)
if os.path.isfile(test_path):
# Yield to the existing file
return true
# See if there's a hand-written file already
if not file_missing_or_overwritable(output_path):
return true
# We made it through, so don't skip
return false
def parse_and_output_man_pages(paths, output_directory, yield_to_dirs, show_progress):
global diagnostic_indent, CMDNAME
paths.sort()