Rev 9615 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
## 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`R_PAPERSIZE=${R_PAPERSIZE:-a4}revision='$Revision: 1.3.6.1 $'version=`set - ${revision}; echo ${2}`version="Rd2dvi ${version}"usage="Usage: R CMD Rd2dvi [options] filesGenerate DVI (or PDF) output from the Rd sources specified by files, byeither giving the paths to the files, or the path to a directory withthe sources of a package.Options:--debug turn on shell debugging (set -x)-h, --help print short help message and exit--no-clean do not remove created temporary files--no-preview do not preview generated output file--output=FILE write output to FILE--pdf generate PDF output--title=NAME use NAME as the title of the document-v, --version print version info and exit-V, --verbose report on what is doneReport bugs to <R-bugs@lists.r-project.org>."start_dir=`pwd`clean=truedebug=falsedvi_ext="dvi"output=""preview=${xdvi:-xdvi.bat}verbose=falseTEXINPUTS=.:${R_HOME}/doc/manual:${TEXINPUTS}file_sed='s/[_$]/\\\\&/g'while test -n "${1}"; docase ${1} in-h|--help)echo "${usage}"; exit 0 ;;-v|--version)echo "${version}"; exit 0 ;;--debug)debug=true ;;--no-clean)clean=false ;;--no-preview)preview=false ;;--pdf)dvi_ext="pdf";preview=false;R_RD4DVI=${R_RD4PDF:-"ae,hyper"};R_LATEXCMD=${PDFLATEX:-pdflatex};;--title=*)title=`echo "${1}" | sed -e 's/[^=]*=//'` ;;--output=*)output=`echo "${1}" | sed -e 's/[^=]*=//'` ;;-V|--verbose)verbose=echo ;;--|*)break ;;esacshiftdoneif test -z "${output}"; thenoutput=Rd2.${dvi_ext}fiif ${debug}; then set -x; fitoc="\\Rdcontents{\\R{} objects documented:}"if [ ${#} -eq 1 -a -d ${1} ]; thenif test -d ${1}/man; thendir=${1}/manelsedir=${1}fi${verbose} "Rd2dvi: \`Rdconv -t latex' ${dir}/ Rd files ..."files=`LC_ALL=C find ${dir} -name "*.[Rr]d" -print | \sed -e '/unix\//d' | sort`subj="all in \\file{`echo ${dir} | sed ${file_sed}`}"${verbose} "files = ${files}"elsefiles="${@}"if [ ${#} -gt 1 ]; thensubj=" etc.";elsesubj=toc=fisubj="\\file{`echo ${1} | sed ${file_sed}`}${subj}"${verbose} "Rd2dvi: Collecting files and \`Rdconv -t latex'ing them ..."fi${verbose} ""${verbose} "subj: ${subj}"${verbose} ""if test -f ${output}; thenecho "file \`${output}' 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}sed 's/markright{#1}/markboth{#1}{#1}/' \${R_HOME}/doc/manual/Rd.sty > ${build_dir}/Rd.stytitle=${title:-"\\R{} documentation}} \\par\\bigskip{{\\Large of ${subj}"}cat > ${build_dir}/Rd2.tex <<EOF\\documentclass[${R_PAPERSIZE}paper]{book}\\usepackage[${R_RD4DVI:-ae}]{Rd}\\usepackage{makeidx}\\makeindex\\begin{document}\\chapter*{}\\begin{center}{\\textbf{\\huge ${title}}}\\par\\medskip{\\large \\today}\\end{center}${TOC}EOFfor f in ${files}; do${verbose} ${f}${R_HOME}/bin/Rdconv.bat -t latex ${f} >> ${build_dir}/Rd2.texdonecat >> ${build_dir}/Rd2.tex <<EOF\\printindex\\end{document}EOFcd ${build_dir}${R_LATEXCMD:-latex} Rd2${R_MAKEINDEXCMD:-makeindex} Rd2${R_LATEXCMD:-latex} Rd2cp Rd2.${dvi_ext} ../${output}cd ${start_dir}if ${clean}; thenrm -rf ${build_dir}elseecho "You may want to clean up by \`rm -rf ${build_dir}'"fi${preview} ${output}exit 0### Local Variables: ***### mode: sh ***### sh-indentation: 2 ***### End: ***