Rev 6994 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#!/bin/sh# Rd2dvi -- check man pages (*.Rd help files) by LaTeX..## Examples:# R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd# R CMD Rd2dvi `grep -l "\\keyword\\{distr" \# /path/to/Rsrc/src/library/base/man/*.Rd | sort | uniq`START_DIR=`pwd`CLEAN=trueDEBUG=falseUSE_XDVI=truefile_sed='s/[_$]/\\\\&/g'while test -n "${1}"; docase ${1} in--clean=[nN]*)CLEAN=false ;;--clean=[yY]*)CLEAN=true ;;--debug=[nN]*)DEBUG=false ;;--debug=[yY]*)DEBUG=true ;;--use-xdvi=[nN]*)USE_XDVI=false ;;--use-xdvi=[yY]*)USE_XDVI=true ;;--|*)break ;;esacshiftdoneTOC="\\Rdcontents{\\R{} objects documented:}"if [ ${#} -eq 1 -a -d ${1} ]; thenif test -d ${1}/man; thendir=${1}/manelsedir=${1}fiif ${DEBUG}; thenecho "Rd2dvi: \`Rdconv -t latex' ${dir}/ Rd files ..."fifiles=`find ${dir} -name "*.[Rr]d" -print`subj="all in \\file{`echo ${dir} | sed ${file_sed}`}"if ${DEBUG}; thenecho "files = ${files}"fielsefiles="${@}"if [ ${#} -gt 1 ]; thensubj=" etc.";elsesubj=TOC=fisubj="\\file{`echo ${1} | sed ${file_sed}`}${subj}"if ${DEBUG}; thenecho "Rd2dvi: Collecting files and \`Rdconv -t latex'ing them ..."fifiif ${DEBUG}; thenecho ""; echo "subj:"; echo "${subj}"; echo ""fiif test -f Rd2.dvi; thenecho "file \`Rd2.dvi' exists; please remove first"exit 1fiBUILD_DIR=.Rd2dvi${$}if test -d ${BUILD_DIR}; thenrm -rf ${BUILD_DIR} || echo "cannot write to build dir" && exit 2fimkdir ${BUILD_DIR}cd ${BUILD_DIR}sed 's/markright{#1}/markboth{#1}{#1}/' \${R_HOME}/doc/manual/Rd.sty > Rd2.stycat > Rd2.tex <<EOF\\documentclass[${R_PAPERSIZE}]{book}\\usepackage{Rd2}\\usepackage{makeidx}\\makeindex\\begin{document}\\chapter*{}\\begin{center}{\\textbf{\\huge\\R{} documentation}}\\par\\bigskip{\\Large of ${subj}}\\par\\medskip{\\large \\today}\\end{center}${TOC}EOFfor f in ${files}; doif ${DEBUG}; then echo ${f}; fiR CMD Rdconv -t latex ${f} >> Rd2.texdonecat >> Rd2.tex <<EOF\\printindex\\end{document}EOF${R_LATEXCMD} Rd2${R_MAKEINDEXCMD} Rd2${R_LATEXCMD} Rd2cp Rd2.dvi ..cd ${START_DIR}if ${CLEAN}; thenrm -rf ${BUILD_DIR}elseecho "You may want to clean up by \`rm -rf ${BUILD_DIR}'"fiif ${USE_XDVI}; thenxdvi Rd2.dvifi