Bram,
I thought about adding a test to check the availability of URLs. Here is
a test script. However I did not add it to the test suite, as it takes
some time. But it already finds some unreachable URLs.
Christian
--
Ernährt euch von Diäten! Unsere Politiker können nicht irren.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
" 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)
func Test_check_URLs()
if !executable('curl') || has("win32")
return
endif
let pat='\(https\?\|ftp\)://[^\t* ]\+'
exe 'helpgrep' pat
helpc
let urls = map(getqflist(), 'v:val.text')
" do not use submatch(1)!
let urls = map(urls, {key, val -> matchstr(val, g: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\|hostname\|file\)\>'})
new
put =urls
" remove some more invalid items
v/./d
g/=$/d
" remove trailing stuff (parenthesis, dot, comma, quotes), but only for HTTP
" links
g/^h/s#[.,)'"/][:.]\?$##
g#^[hf]t\?tp:/\(/\?\.*\)$#d
%d
let a = getline(1,'$')
let a = uniq(sort(a))
call setline(1, a)
%s/.*/\=TestURL(submatch(0))/
endfunc
func TestURL(url)
" Note: does not follow redirects!
call system('curl --silent --fail --output /dev/null --head '.
shellescape(a:url))
return printf("%s %d", a:url, v:shell_error)
endfunc