Rev 4644 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/bin/sh# Rd2dvi -- check man pages (*.Rd help files) by LaTeX..#if [ $# -eq 0 -o x$1 = x-h -o x$1 = x--help ]thencat <<_EOF_Rd2dvi : Convert R man pages (Rd files) to latex and dviUSAGE: R CMD Rd2dvi <dir or files>- When a directory is given as argument, it should be a source'package' directory, or its 'man' subdirectory, and all its files aretaken. This is convenient for nice documentation checkingof a package.- When files are given, they must be Rd files.All the files are converted to LaTeX and concatenated;they are LaTeXed and indexed;Finally, 'xdvi' is started on the result if available.EXAMPLES :# All from R's RHOME (source!) directorycd \`R RHOME\`R CMD Rd2dvi src/library/base/man/Normal.RdR CMD Rd2dvi src/library/modregR CMD Rd2dvi \`grep -l '\\keyword{distr' src/library/base/man/*.Rd |sort|uniq\`_EOF_exit 1fiPwd=`dirname $0`RHOME=${Pwd}/..MANTEXDIR=${RHOME}/doc/manualD2L="${Pwd}/Rdconv -t latex"#call_dir=`pwd`if [ -f Rd2.tex ]thenecho "'Rd2.tex' already exists -- renaming it to Rd2.tex.Older"echo " -------- "mv Rd2.tex Rd2.tex.Olderfitouch Rd2.texif [ $# -eq 1 -a -d $1 ]thendir=$1test -d $dir/man && dir=$dir/manecho "Rd2dvi : \`Rdconv -t latex' $dir/ files..."files="${dir}/*.Rd"subj="of all in $dir"# DBG: echo "files = $files"toc_sed='; s/\\input{Rd/\\Rdcontents{\\R\\ objects documented:} &/'elsefiles="$@"subj="of $1"toc_sed=''if [ $# -gt 1 ]; then subj="$subj ...etc "; fiecho "Rd2dvi : Collecting files and \`Rdconv -t latex' them ..."fifor f in $filesdoecho $f$D2L $f >> Rd2.texdoneecho "MANTEXDIR='$MANTEXDIR'"R_P=`echo 'getenv("R_PAPERSIZE")'| R --vanilla --quiet|grep -v getenv|grep '"'|sed 's/ *//g;s/"//g'`sed "s/a4paper/${R_P}paper/; s| documentation |& ${subj} |; ${toc_sed}" \${MANTEXDIR}/Rd2dvi.tex > Rd2dvi.texif [ ! -f Rd.sty ]; thensed 's/markright{#1}/markboth{#1}{#1}/' ${MANTEXDIR}/Rd.sty > Rd2.styfi#exit#---------------------latex Rd2dviif [ -x `/usr/bin/which makeindex` ]then makeindex Rd2dvilatex Rd2dvifiif [ -x `/usr/bin/which xdvi` ]then xdvi Rd2dvi &fiecho ''echo 'Rd2dvi: You may want to clean up by'echo ' rm -f Rd2dvi.* Rd2.sty Rd2.tex*'echo ''