help.fish: fix help for the separate completion page

This commit is contained in:
Johannes Altmanninger 2020-05-16 11:19:45 +02:00
parent 8e18f683a7
commit f9447dc72f
3 changed files with 14 additions and 9 deletions

View file

@ -2,7 +2,7 @@ if test -d "$__fish_data_dir/man/man1/"
complete -c help -x -a '(__fish_print_commands)' -d 'Help for this command'
end
# Help topics
# Help topics in index.html
# This was semi-automated with `grep 'class="anchor"' -A1 /usr/share/doc/fish/index.html
# It's not fully automated since that requires parsing html with regex,
# and since this is by definition in sync - we ship the html, and we ship these completions.
@ -11,12 +11,7 @@ complete -c help -x -a builtin-overview -d 'Builtin commands'
complete -c help -x -a cartesian-product -d 'Cartesian Products'
complete -c help -x -a color -d 'Setting syntax highlighting colors'
complete -c help -x -a combine -d 'Combining different expansions'
complete -c help -x -a completion -d 'How tab-completion works'
complete -c help -x -a completion-func -d 'Useful functions for writing completions'
complete -c help -x -a completion-own -d 'Writing your own completions'
complete -c help -x -a completion-path -d 'Where to put completions'
complete -c help -x -a debugging -d 'Debugging fish scripts'
complete -c help -x -a docs -d Help
complete -c help -x -a editor -d 'Command line editor'
complete -c help -x -a emacs-mode -d 'Emacs mode commands'
complete -c help -x -a escapes -d 'Escaping characters'
@ -56,9 +51,10 @@ complete -c help -x -a syntax-function-autoloading -d 'Autoloading functions'
complete -c help -x -a syntax-function-wrappers -d 'Defining aliases'
complete -c help -x -a syntax-job-control -d 'Job control'
complete -c help -x -a syntax-words -d 'Some common words'
complete -c help -x -a tab-completion -d 'How tab-completion works'
complete -c help -x -a title -d 'Programmable title'
complete -c help -x -a variables -d 'Shell variables'
complete -c help -x -a variables-arrays -d Arrays
complete -c help -x -a variables-lists -d Lists
complete -c help -x -a variables-color -d 'Variables for changing highlighting colors'
complete -c help -x -a variables-export -d 'Exporting variables'
complete -c help -x -a variables-functions -d 'Variable scope for functions'
@ -72,6 +68,11 @@ complete -c help -x -a vi-mode-command -d 'Command mode'
complete -c help -x -a vi-mode-insert -d 'Insert mode'
complete -c help -x -a vi-mode-visual -d 'Visual mode'
# Completions
complete -c help -x -a completion-own -d 'Writing your own completions'
complete -c help -x -a completion-func -d 'Useful functions for writing completions'
complete -c help -x -a completion-path -d 'Where to put completions'
# Tutorial
complete -c help -x -a tutorial -d Tutorial
complete -c help -x -a tut_autoload -d 'Autoloading Functions'

View file

@ -1,7 +1,9 @@
function __fish_print_commands --description "Print a list of documented fish commands"
if test -d $__fish_data_dir/man/man1/
for file in $__fish_data_dir/man/man1/**.1*
string replace -r '.*/' '' -- $file | string replace -r '.1(.gz)?$' ''
string replace -r '.*/' '' -- $file |
string replace -r '.1(.gz)?$' '' |
string match -rv '^fish-(?:completions|doc|tutorial|faq)$'
end
end
end

View file

@ -18,7 +18,6 @@ function help --description 'Show help for the fish shell'
end
end
#
# Find a suitable browser for viewing the help pages.
# The first thing we try is $fish_help_browser.
set -l fish_browser $fish_help_browser
@ -112,6 +111,7 @@ function help --description 'Show help for the fish shell'
end
end
set -l fish_help_page
switch "$fish_help_item"
case "."
set fish_help_page "cmds/source.html"
@ -119,6 +119,8 @@ function help --description 'Show help for the fish shell'
set fish_help_page "index.html#expand"
case (__fish_print_commands)
set fish_help_page "cmds/$fish_help_item.html"
case 'completion-*'
set fish_help_page "completions.html#$fish_help_item"
case 'tut_*'
set fish_help_page "tutorial.html#"(string sub -s 5 -- $fish_help_item | string replace -a -- _ -)
case tutorial