doc.kak: Also search through plugins (stdlib and per-user) for docs.

This makes the somewhat-dubious assumption that every plugin will have uniquely-
named documentation files, instead of automatically putting every plugin's docs
into a namespace. However, plugins already have to deal with flat namespaces for
commands, options, filetypes, etc. so one more shouldn't hurt.

Fixes #2466.
This commit is contained in:
Tim Allen 2020-09-03 01:19:20 +10:00
parent e0d2602e6a
commit 4296305171

View File

@ -137,9 +137,19 @@ define-command -params 1 -hidden doc-render %{
define-command -params 1..2 \ define-command -params 1..2 \
-shell-script-candidates %{ -shell-script-candidates %{
if [ "$kak_token_to_complete" -eq 0 ]; then if [ "$kak_token_to_complete" -eq 0 ]; then
find "${kak_runtime}/doc/" -type f -name "*.asciidoc" | sed 's,.*/,,; s/\.[^/]*$//' (
find "${kak_runtime}/doc/" -type f -name "*.asciidoc"
find "${kak_runtime}/rc/" -type f -name "*.asciidoc"
find "${kak_config}/autoload/" -type f -name "*.asciidoc"
) | sed 's,.*/,,; s/\.[^/]*$//'
elif [ "$kak_token_to_complete" -eq 1 ]; then elif [ "$kak_token_to_complete" -eq 1 ]; then
readonly page="${kak_runtime}/doc/${1}.asciidoc" page=$(
(
find "${kak_runtime}/doc/" -type f -name "$1.asciidoc"
find "${kak_runtime}/rc/" -type f -name "$1.asciidoc"
find "${kak_config}/autoload/" -type f -name "$1.asciidoc"
) | head -1
)
if [ -f "${page}" ]; then if [ -f "${page}" ]; then
awk ' awk '
/^==+ +/ { sub(/^==+ +/, ""); print } /^==+ +/ { sub(/^==+ +/, ""); print }
@ -153,7 +163,13 @@ define-command -params 1..2 \
An optional keyword argument can be passed to the function, which will be automatically selected in the documentation An optional keyword argument can be passed to the function, which will be automatically selected in the documentation
} %{ } %{
evaluate-commands %sh{ evaluate-commands %sh{
readonly page="${kak_runtime}/doc/${1}.asciidoc" page=$(
(
find "${kak_runtime}/doc/" -type f -name "$1.asciidoc"
find "${kak_runtime}/rc/" -type f -name "$1.asciidoc"
find "${kak_config}/autoload/" -type f -name "$1.asciidoc"
) | head -1
)
if [ -f "${page}" ]; then if [ -f "${page}" ]; then
jump_cmd="" jump_cmd=""
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then