[ca3a90]: / format-help.zsh  Maximize  Restore  History

Download this file

135 lines (126 with data), 3.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/zsh
emulate -L zsh
typeset -gr DEVDIR=$0:a:h:h
typeset -gr STUFDIR=$0:a:h
typeset -gr DOCDB=~/.db/vim-help-times.dat
. $STUFDIR/gettemp.zsh format-help
typeset -gr DOCDIR=$TMPDIR/doc
setopt extendedglob
setopt nullglob
setopt rcquotes
typeset -gr P=$0:t
function help()
{
local s=${P//?/ }
cat <<EOF
EOF
exit 0
}
[[ $1 == --help ]] && help
if [[ $1 == --nopost ]] ; then
typeset -gir NOPOST=1
shift
else
typeset -gir NOPOST=0
fi
if [[ $1 == --foreground ]] ; then
typeset -gr EXITARG
typeset -gar ADDJOB
shift
else
EXITARG="|qa!"
ADDJOB=( addjob )
typeset -gr EXITARG
typeset -gar ADDJOB
fi
function plugtxt()
{
if [[ -d ${REPLY}/doc ]] ; then
reply=( ${REPLY}/doc/*.(txt|??x) )
else
return 1
fi
}
function plugs()
{
[[ -e ${REPLY}/${REPLY:t}-addon-info.txt ]]
}
function format()
{
local helpfile
for helpfile in $@ ; do
local htmlfile=$helpfile.html
if [[ $helpfile[-1] == 'x' ]] ; then
local lang=$helpfile[-3,-2]
local tags=./tags-$lang,./tags
else
local lang=en
local tags=./tags
fi
$ADDJOB \
/home/zyx/bin/vim \
-R -u NONE --cmd 'set nocompatible t_Co=256 bg=light' \
--cmd 'let &rtp.=",".$RTPS' \
--cmd 'syntax on' \
-c "set ft=help cole=2 nolist hlg=$lang tag=$tags" \
-c 'let g:format_IgnoreTags=0' \
-c 'let g:format_FormatConcealed=1' \
-c 'let g:format_FormatMatches="none"' \
-c 'let g:format_HTMLUseTagNameInAnchor=1' \
-c 'let g:format_StartTagReg=''|\|\%(''''\l\)\@=''' \
-c 'let g:format_EndTagReg=''\%(\l''''\)\@<=\*\@!\||''' \
-c 'runtime! plugin/format.vim' \
-c "Format format html to ${htmlfile}${EXITARG}" \
$helpfile
done
waitjobs
}
. $STUFDIR/parjobs.zsh
function printjob()
{
echo -n ${${${(P)1}[-1]}:t}
}
local -A helpfiletimes
if test -r $DOCDB ; then
helpfiletimes=( $(< $DOCDB) )
fi
mkdir -p $DOCDIR
local -a helpfiles
local -a allhelpfiles
hg -R ~/a.a/Proj/c/vim-upstream pull -u -r upstream
for helpfile in $DEVDIR/*(/+plugtxt) \
~/a.a/Proj/c/vim-upstream/runtime/doc/*.(txt|??x)(^@)
do
local hf=$helpfile:t
local -i modtime=$(stat -c %Y $helpfile)
allhelpfiles+=( $helpfile )
if (( ${+helpfiletimes[$hf]} )) && (( ${helpfiletimes[$hf]}>=$modtime ))
then
continue
else
helpfiles+=( $hf )
helpfiletimes[$hf]=$modtime
fi
done
if (( !$#helpfiles && !$# )) ; then
echo 'No new help files found' >&2
exit 1
fi
for helpfile in $allhelpfiles ; do
cp $helpfile $DOCDIR
done
vim -u NONE -c "execute 'helptags '.fnameescape(${(qqq)DOCDIR})" -c 'qa!'
cd $DOCDIR
set -A RTP ${DEVDIR}/*(/+plugs)
export RTPS=${(j.,.)RTP}
export DOCDIR
if (( $# )) ; then
format $DOCDIR/${^@}
else
format $DOCDIR/$^helpfiles
fi
if ! (( NOPOST )) ; then
scp $DOCDIR/*.html zyxsf,vimpluginloader@web.sourceforge.net:/home/groups/v/vi/vimpluginloader/htdocs/doc \
&& echo ${(kv)helpfiletimes} > $DOCDB
$STUFDIR/helptags.zsh
fi