mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:9.0.0110: help tag generation picks up words in code examples
Problem: Help tag generation picks up words in code examples.
Solution: Skip over examples. (Carlo Teubner, closes vim/vim#10813)
ddab3ce345
Also fix mistakes in help files.
Co-authored-by: Carlo Teubner <carlo@cteubner.net>
This commit is contained in:
@@ -8003,7 +8003,7 @@ stridx({haystack}, {needle} [, {start}]) *stridx()*
|
|||||||
|
|
||||||
Can also be used as a |method|: >
|
Can also be used as a |method|: >
|
||||||
GetHaystack()->stridx(needle)
|
GetHaystack()->stridx(needle)
|
||||||
|
<
|
||||||
*string()*
|
*string()*
|
||||||
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
|
string({expr}) Return {expr} converted to a String. If {expr} is a Number,
|
||||||
Float, String, Blob or a composition of them, then the result
|
Float, String, Blob or a composition of them, then the result
|
||||||
|
@@ -1780,7 +1780,7 @@ v:exiting Exit code, or |v:null| before invoking the |VimLeavePre|
|
|||||||
and |VimLeave| autocmds. See |:q|, |:x| and |:cquit|.
|
and |VimLeave| autocmds. See |:q|, |:x| and |:cquit|.
|
||||||
Example: >
|
Example: >
|
||||||
:au VimLeave * echo "Exit value is " .. v:exiting
|
:au VimLeave * echo "Exit value is " .. v:exiting
|
||||||
|
<
|
||||||
*v:echospace* *echospace-variable*
|
*v:echospace* *echospace-variable*
|
||||||
v:echospace Number of screen cells that can be used for an `:echo` message
|
v:echospace Number of screen cells that can be used for an `:echo` message
|
||||||
in the last screen line before causing the |hit-enter-prompt|.
|
in the last screen line before causing the |hit-enter-prompt|.
|
||||||
|
@@ -941,6 +941,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
|
|||||||
}
|
}
|
||||||
const char *const fname = files[fi] + dirlen + 1;
|
const char *const fname = files[fi] + dirlen + 1;
|
||||||
|
|
||||||
|
bool in_example = false;
|
||||||
bool firstline = true;
|
bool firstline = true;
|
||||||
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) {
|
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int) {
|
||||||
if (firstline) {
|
if (firstline) {
|
||||||
@@ -971,6 +972,13 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
|
|||||||
}
|
}
|
||||||
firstline = false;
|
firstline = false;
|
||||||
}
|
}
|
||||||
|
if (in_example) {
|
||||||
|
// skip over example; a non-white in the first column ends it
|
||||||
|
if (vim_strchr(" \t\n\r", IObuff[0])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
in_example = false;
|
||||||
|
}
|
||||||
p1 = vim_strchr((char *)IObuff, '*'); // find first '*'
|
p1 = vim_strchr((char *)IObuff, '*'); // find first '*'
|
||||||
while (p1 != NULL) {
|
while (p1 != NULL) {
|
||||||
p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'.
|
p2 = strchr((const char *)p1 + 1, '*'); // Find second '*'.
|
||||||
@@ -990,7 +998,7 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
|
|||||||
|| s[1] == '\0')) {
|
|| s[1] == '\0')) {
|
||||||
*p2 = '\0';
|
*p2 = '\0';
|
||||||
p1++;
|
p1++;
|
||||||
size_t s_len= (size_t)(p2 - p1) + strlen(fname) + 2;
|
size_t s_len = (size_t)(p2 - p1) + strlen(fname) + 2;
|
||||||
s = xmalloc(s_len);
|
s = xmalloc(s_len);
|
||||||
GA_APPEND(char *, &ga, s);
|
GA_APPEND(char *, &ga, s);
|
||||||
snprintf(s, s_len, "%s\t%s", p1, fname);
|
snprintf(s, s_len, "%s\t%s", p1, fname);
|
||||||
@@ -1001,6 +1009,11 @@ static void helptags_one(char *dir, const char *ext, const char *tagfname, bool
|
|||||||
}
|
}
|
||||||
p1 = p2;
|
p1 = p2;
|
||||||
}
|
}
|
||||||
|
size_t len = strlen(IObuff);
|
||||||
|
if ((len == 2 && strcmp(&IObuff[len - 2], ">\n") == 0)
|
||||||
|
|| (len >= 3 && strcmp(&IObuff[len - 3], " >\n") == 0)) {
|
||||||
|
in_example = true;
|
||||||
|
}
|
||||||
line_breakcheck();
|
line_breakcheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -156,6 +156,13 @@ func Test_helptag_cmd()
|
|||||||
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
|
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
|
||||||
call delete('Xdir/tags')
|
call delete('Xdir/tags')
|
||||||
|
|
||||||
|
" Test parsing tags
|
||||||
|
call writefile(['*tag1*', 'Example: >', ' *notag*', 'Example end: *tag2*'],
|
||||||
|
\ 'Xdir/a/doc/sample.txt')
|
||||||
|
helptags Xdir
|
||||||
|
call assert_equal(["tag1\ta/doc/sample.txt\t/*tag1*",
|
||||||
|
\ "tag2\ta/doc/sample.txt\t/*tag2*"], readfile('Xdir/tags'))
|
||||||
|
|
||||||
" Duplicate tags in the help file
|
" Duplicate tags in the help file
|
||||||
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
|
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
|
||||||
call assert_fails('helptags Xdir', 'E154:')
|
call assert_fails('helptags Xdir', 'E154:')
|
||||||
|
Reference in New Issue
Block a user