mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 02:31:18 -03:00
Make create_manpage_completions not generate empty files
https://github.com/fish-shell/fish-shell/issues/506
This commit is contained in:
@@ -132,7 +132,10 @@ def builtcommand(options, description):
|
|||||||
|
|
||||||
# Here's what we'll use to truncate if necessary
|
# Here's what we'll use to truncate if necessary
|
||||||
max_description_width = 63
|
max_description_width = 63
|
||||||
truncation_suffix = u'… [See Man Page]'
|
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
|
# Try to include as many whole sentences as will fit
|
||||||
sentences = description.split('.')
|
sentences = description.split('.')
|
||||||
@@ -776,6 +779,9 @@ def parse_manpage_at_path(manpage_path, yield_to_dirs, output_directory):
|
|||||||
diagnostic_indent += 1
|
diagnostic_indent += 1
|
||||||
success = parser.parseManPage(manpage)
|
success = parser.parseManPage(manpage)
|
||||||
diagnostic_indent -= 1
|
diagnostic_indent -= 1
|
||||||
|
# Make sure empty files aren't reported as success
|
||||||
|
if not built_command_output:
|
||||||
|
success = False
|
||||||
if success:
|
if success:
|
||||||
PARSER_INFO.setdefault(parser_name, []).append(CMDNAME)
|
PARSER_INFO.setdefault(parser_name, []).append(CMDNAME)
|
||||||
break
|
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)
|
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' % manpage_path, BRIEF_VERBOSE)
|
||||||
add_diagnostic('%s contains no options or is unparsable (tried parser %s)' % (manpage_path, parser_names), 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
|
return success
|
||||||
|
|
||||||
# Indicates whether the given filename has a presence in one of the yield-to directories
|
# 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 True
|
||||||
return False
|
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):
|
def parse_and_output_man_pages(paths, output_directory, yield_to_dirs, show_progress):
|
||||||
global diagnostic_indent, CMDNAME
|
global diagnostic_indent, CMDNAME
|
||||||
paths.sort()
|
paths.sort()
|
||||||
|
|||||||
Reference in New Issue
Block a user