mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
Adjust __fish_print_help for sphinx
This is beyond cheesy, but it seems to work. Fixes #5782.
This commit is contained in:
parent
8f1b240289
commit
25dd22242d
1 changed files with 13 additions and 4 deletions
|
@ -52,6 +52,7 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
# blank line, to duplicate the default behavior of `man`, or more accurately,
|
# blank line, to duplicate the default behavior of `man`, or more accurately,
|
||||||
# the `-s` flag to `less` that `man` passes.
|
# the `-s` flag to `less` that `man` passes.
|
||||||
set -l state blank
|
set -l state blank
|
||||||
|
set -l have_name
|
||||||
for line in $help
|
for line in $help
|
||||||
# categorize the line
|
# categorize the line
|
||||||
set -l line_type
|
set -l line_type
|
||||||
|
@ -69,24 +70,32 @@ function __fish_print_help --description "Print help message for the specified f
|
||||||
case ''
|
case ''
|
||||||
set line_type blank
|
set line_type blank
|
||||||
case '*'
|
case '*'
|
||||||
|
# Remove man's bolding
|
||||||
|
set -l name (string replace -ra '(.)'\b'.' '$1' -- $line)
|
||||||
|
# We start after we have the name
|
||||||
|
contains -- $name NAME; and set have_name 1; and continue
|
||||||
|
# We ignore the SYNOPSIS header
|
||||||
|
contains -- $name SYNOPSIS; and continue
|
||||||
|
# Everything after COPYRIGHT is useless
|
||||||
|
contains -- $name COPYRIGHT; and break
|
||||||
|
|
||||||
# not leading space, and not empty, so must contain a non-space
|
# not leading space, and not empty, so must contain a non-space
|
||||||
# in the first column. That makes it a header/footer.
|
# in the first column. That makes it a header/footer.
|
||||||
set line_type meta
|
set line_type meta
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set -q have_name[1]; or continue
|
||||||
switch $state
|
switch $state
|
||||||
case normal
|
case normal
|
||||||
switch $line_type
|
switch $line_type
|
||||||
case normal
|
case normal meta
|
||||||
printf "%s\n" $line
|
printf "%s\n" $line
|
||||||
case blank
|
case blank
|
||||||
set state blank
|
set state blank
|
||||||
case meta
|
|
||||||
# skip it
|
|
||||||
end
|
end
|
||||||
case blank
|
case blank
|
||||||
switch $line_type
|
switch $line_type
|
||||||
case normal
|
case normal meta
|
||||||
echo # print the blank line
|
echo # print the blank line
|
||||||
printf "%s\n" $line
|
printf "%s\n" $line
|
||||||
set state normal
|
set state normal
|
||||||
|
|
Loading…
Reference in a new issue