diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/check_urls.vim | 68 | ||||
-rwxr-xr-x | scripts/gen_api_vimdoc.py | 21 | ||||
-rw-r--r-- | scripts/genvimvim.lua | 6 | ||||
-rwxr-xr-x | scripts/update_terminfo.sh | 89 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 31 |
5 files changed, 202 insertions, 13 deletions
diff --git a/scripts/check_urls.vim b/scripts/check_urls.vim new file mode 100644 index 0000000000..3580b79475 --- /dev/null +++ b/scripts/check_urls.vim @@ -0,0 +1,68 @@ +" Test for URLs in help documents. +" +" Opens a new window with all found URLS followed by return code from curl +" (anything other than 0 means unreachable) +" +" Written by Christian Brabandt. + +func Test_check_URLs() + if has("win32") + echoerr "Doesn't work on MS-Windows" + return + endif + if executable('curl') + " Note: does not follow redirects! + let s:command = 'curl --silent --fail --output /dev/null --head ' + elseif executable('wget') + " Note: only allow a couple of redirects + let s:command = 'wget --quiet -S --spider --max-redirect=2 --timeout=5 --tries=2 -O /dev/null ' + else + echoerr 'Only works when "curl" or "wget" is available' + return + endif + + let pat='\(https\?\|ftp\)://[^\t* ]\+' + exe 'helpgrep' pat + helpclose + + let urls = map(getqflist(), 'v:val.text') + " do not use submatch(1)! + let urls = map(urls, {key, val -> matchstr(val, pat)}) + " remove examples like user@host (invalid urls) + let urls = filter(urls, 'v:val !~ "@"') + " Remove example URLs which are invalid + let urls = filter(urls, {key, val -> val !~ '\<\(\(my\|some\)\?host\|machine\|hostname\|file\)\>'}) + new + put =urls + " remove some more invalid items + " empty lines + v/./d + " remove # anchors + %s/#.*$//e + " remove trailing stuff (parenthesis, dot, comma, quotes), but only for HTTP + " links + g/^h/s#[.,)'"/>][:.]\?$## + g#^[hf]t\?tp:/\(/\?\.*\)$#d + silent! g/ftp://,$/d + silent! g/=$/d + let a = getline(1,'$') + let a = uniq(sort(a)) + %d + call setline(1, a) + + " Do the testing. + set nomore + %s/.*/\=TestURL(submatch(0))/ + + " highlight the failures + /.* \([0-9]*[1-9]\|[0-9]\{2,}\)$ +endfunc + +func TestURL(url) + " Relies on the return code to determine whether a page is valid + echom printf("Testing URL: %d/%d %s", line('.'), line('$'), a:url) + call system(s:command . shellescape(a:url)) + return printf("%s %d", a:url, v:shell_error) +endfunc + +call Test_check_URLs() diff --git a/scripts/gen_api_vimdoc.py b/scripts/gen_api_vimdoc.py index 0bbc3706c6..4e86f15b37 100755 --- a/scripts/gen_api_vimdoc.py +++ b/scripts/gen_api_vimdoc.py @@ -413,10 +413,26 @@ def gen_docs(config): sys.exit(p.returncode) sections = {} + intros = {} sep = '=' * text_width base = os.path.join(out_dir, 'xml') dom = minidom.parse(os.path.join(base, 'index.xml')) + + # generate docs for section intros + for compound in dom.getElementsByTagName('compound'): + if compound.getAttribute('kind') != 'group': + continue + + groupname = get_text(find_first(compound, 'name')) + groupxml = os.path.join(base, '%s.xml' % compound.getAttribute('refid')) + + desc = find_first(minidom.parse(groupxml), 'detaileddescription') + if desc: + doc = parse_parblock(desc) + if doc: + intros[groupname] = doc + for compound in dom.getElementsByTagName('compound'): if compound.getAttribute('kind') != 'file': continue @@ -437,6 +453,11 @@ def gen_docs(config): name = name.title() doc = '' + + intro = intros.get('api-%s' % name.lower()) + if intro: + doc += '\n\n' + intro + if functions: doc += '\n\n' + functions diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 24c147b811..947aef6cb5 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -85,7 +85,7 @@ local vimau_start = 'syn keyword vimAutoEvent contained ' w('\n\n' .. vimau_start) for _, au in ipairs(auevents.events) do - if not auevents.neovim_specific[au] then + if not auevents.nvim_specific[au] then if lld.line_length > 850 then w('\n' .. vimau_start) end @@ -93,7 +93,7 @@ for _, au in ipairs(auevents.events) do end end for au, _ in pairs(auevents.aliases) do - if not auevents.neovim_specific[au] then + if not auevents.nvim_specific[au] then if lld.line_length > 850 then w('\n' .. vimau_start) end @@ -104,7 +104,7 @@ end local nvimau_start = 'syn keyword nvimAutoEvent contained ' w('\n\n' .. nvimau_start) -for au, _ in pairs(auevents.neovim_specific) do +for au, _ in pairs(auevents.nvim_specific) do if lld.line_length > 850 then w('\n' .. nvimau_start) end diff --git a/scripts/update_terminfo.sh b/scripts/update_terminfo.sh new file mode 100755 index 0000000000..e3b1692b15 --- /dev/null +++ b/scripts/update_terminfo.sh @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# +# usage: ./scripts/update_terminfo.sh +# +# This script does: +# +# 1. Download Dickey's terminfo.src +# 2. Compile temporary terminfo database from terminfo.src +# 3. Use database to generate src/nvim/tui/terminfo_defs.h +# + +set -e + +url='https://invisible-island.net/datafiles/current/terminfo.src.gz' +target='src/nvim/tui/terminfo_defs.h' + +readonly -A entries=( + [ansi]=ansi_terminfo + [interix]=interix_8colour_terminfo + [iterm2]=iterm_256colour_terminfo + [linux]=linux_16colour_terminfo + [putty-256color]=putty_256colour_terminfo + [rxvt-256color]=rxvt_256colour_terminfo + [screen-256color]=screen_256colour_terminfo + [st-256color]=st_256colour_terminfo + [tmux-256color]=tmux_256colour_terminfo + [vte-256color]=vte_256colour_terminfo + [xterm-256color]=xterm_256colour_terminfo +) + +db="$(mktemp -du)" + +print_bold() { + printf "\\e[1m$*\\e[0m" +} + +cd "$(git rev-parse --show-toplevel)" + +# +# Get terminfo.src +# +print_bold '[*] Get terminfo.src\n' +curl -O "$url" +gunzip -f terminfo.src.gz + +# +# Build terminfo database +# +print_bold '[*] Build terminfo database\n' +tic -x -o "$db" terminfo.src +rm -f terminfo.src + +# +# Write src/nvim/tui/terminfo_defs.h +# +print_bold "[*] Writing $target... " +sorted_terms="$(echo "${!entries[@]}" | tr ' ' '\n' | sort | xargs)" + +cat > "$target" <<EOF +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + +// +// Generated by scripts/update_terminfo.sh and $(tic -V) +// + +#ifndef NVIM_TUI_TERMINFO_DEFS_H +#define NVIM_TUI_TERMINFO_DEFS_H + +#include <stdint.h> +EOF + +for term in $sorted_terms; do + path="$(find "$db" -name "$term")" + if [[ -z $path ]]; then + echo "Not found: $term. Skipping." 1>&2 + continue + fi + echo + infocmp -L -1 -A "$db" "$term" | sed -e '1d' -e 's#^#// #' | tr '\t' ' ' + echo "static const int8_t ${entries[$term]}[] = {" + echo -n " "; od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ',' + echo "};" +done >> "$target" + +cat > "$target" <<EOF +#endif // NVIM_TUI_TERMINFO_DEFS_H +EOF +print_bold 'done\n' diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 22f946ebd9..11305421e5 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -85,14 +85,15 @@ get_vim_sources() { git clone https://github.com/vim/vim.git "${VIM_SOURCE_DIR}" cd "${VIM_SOURCE_DIR}" else - if [[ ! -d "${VIM_SOURCE_DIR}/.git" ]]; then + cd "${VIM_SOURCE_DIR}" + if ! [ -d ".git" ] \ + && ! [ "$(git rev-parse --show-toplevel)" = "${VIM_SOURCE_DIR}" ]; then msg_err "${VIM_SOURCE_DIR} does not appear to be a git repository." echo " Please remove it and try again." exit 1 fi - cd "${VIM_SOURCE_DIR}" echo "Updating Vim sources: ${VIM_SOURCE_DIR}" - git pull && + git pull --ff && msg_ok "Updated Vim sources." || msg_err "Could not update Vim sources; ignoring error." fi @@ -131,7 +132,7 @@ assign_commit_details() { vim_commit_url="https://github.com/vim/vim/commit/${vim_commit}" vim_message="$(cd "${VIM_SOURCE_DIR}" \ && git log -1 --pretty='format:%B' "${vim_commit}" \ - | sed -e 's/\(#[0-9]*\)/vim\/vim\1/g')" + | sed -e 's/\(#[0-9]\{1,\}\)/vim\/vim\1/g')" if [[ ${munge_commit_line} == "true" ]]; then # Remove first line of commit message. vim_message="$(echo "${vim_message}" | sed -e '1s/^patch /vim-patch:/')" @@ -148,15 +149,15 @@ preprocess_patch() { local na_src='proto\|Make*\|gui_*\|if_lua\|if_mzsch\|if_olepp\|if_ole\|if_perl\|if_py\|if_ruby\|if_tcl\|if_xcmdsrv' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<\%(testdir/\)\@<!\%('${na_src}'\)@norm! d/\v(^diff)|%$
' +w +q "$file" - # Remove channel.txt, netbeans.txt, os_*.txt, term.txt, todo.txt, version*.txt, tags - local na_doc='channel\.txt\|netbeans\.txt\|os_\w\+\.txt\|term\.txt\|todo\.txt\|version\d\.txt\|tags' + # Remove unwanted Vim doc files. + local na_doc='channel\.txt\|netbeans\.txt\|os_\w\+\.txt\|term\.txt\|todo\.txt\|version\d\.txt\|sponsor\.txt\|intro\.txt\|tags' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/doc/\<\%('${na_doc}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove "Last change ..." changes in doc files. 2>/dev/null $nvim --cmd 'set dir=/tmp' +'%s/^@@.*\n.*For Vim version.*Last change.*\n.*For Vim version.*Last change.*//' +w +q "$file" - # Remove some testdir/Make_*.mak files - local na_src_testdir='Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms' + # Remove screen dumps, testdir/Make_*.mak files + local na_src_testdir='Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms\|dumps/.*.dump' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\<\%('${na_src_testdir}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove version.c #7555 @@ -178,6 +179,16 @@ preprocess_patch() { # Rename path to matchit plugin. LC_ALL=C sed -e 's@\( [ab]/runtime\)/pack/dist/opt/matchit/\(plugin/matchit.vim\)@\1/\2@g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" + LC_ALL=C sed -e 's@\( [ab]/runtime\)/pack/dist/opt/matchit/doc/\(matchit.txt\)@\1/doc/pi_\2@g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + + # Rename test_urls.vim to check_urls.vim + LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls.vim\)@\1/scripts/check\2@g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + + # Rename path to check_colors.vim + LC_ALL=C sed -e 's@\( [ab]/runtime\)/colors/\(tools/check_colors.vim\)@\1/\2@g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" } get_vimpatch() { @@ -202,7 +213,7 @@ get_vimpatch() { printf "Pre-processing patch...\n" preprocess_patch "${NVIM_SOURCE_DIR}/${patch_file}" - msg_ok "Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'.\n" + msg_ok "Saved patch to '${NVIM_SOURCE_DIR}/${patch_file}'." } stage_patch() { @@ -244,7 +255,7 @@ stage_patch() { else printf "\nApplying patch...\n" patch -p1 < "${patch_file}" || true - find -name '*.orig' -type f -delete + find . -name '*.orig' -type f -delete fi printf "\nInstructions:\n Proceed to port the patch.\n" else |