The R Project SVN R

Rev

Rev 11368 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 11368 Rev 11629
Line 1... Line 1...
1
#!/bin/sh
1
#! /bin/sh
2
#  Rd2dvi -- Convert man pages (*.Rd help files) via LaTeX to DVI/PDF.
-
 
3
#
-
 
4
# Examples:
-
 
5
#  R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd
-
 
6
#  R CMD Rd2dvi `grep -l "\\keyword{distr" \
-
 
7
#                  /path/to/Rsrc/src/library/base/man/*.Rd | sort | uniq`
-
 
8
 
2
 
-
 
3
## Rd2dvi -- Convert man pages (*.Rd help files) via LaTeX to DVI/PDF.
-
 
4
##
-
 
5
## Examples:
-
 
6
##  R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd
-
 
7
##  R CMD Rd2dvi `grep -l "\\keyword{distr" \
-
 
8
##                  /path/to/Rsrc/src/library/base/man/*.Rd | sort | uniq`
-
 
9
 
9
revision='$Revision: 1.23 $'
10
revision='$Revision: 1.23.2.1 $'
10
version=`set - ${revision}; echo ${2}`
11
version=`set - ${revision}; echo ${2}`
11
version="Rd2dvi ${version}" 
12
version="Rd2dvi ${version}
-
 
13
 
-
 
14
Copyright (C) 2000 The R Core Development Team.
-
 
15
This is free software; see the GNU General Public Licence version 2
-
 
16
or later for copying conditions.  There is NO warranty." 
12
 
17
 
13
usage="Usage: R CMD Rd2dvi [options] files
18
usage="Usage: R CMD Rd2dvi [options] files
14
 
19
 
15
Generate DVI (or PDF) output from the Rd sources specified by files, by
20
Generate DVI (or PDF) output from the Rd sources specified by files, by
16
either giving the paths to the files, or the path to a directory with
21
either giving the paths to the files, or the path to a directory with
17
the sources of a package.
22
the sources of a package.
18
 
23
 
19
Options:
24
Options:
20
  --debug		turn on shell debugging (set -x)
-
 
21
  -h, --help		print short help message and exit
25
  -h, --help		print short help message and exit
-
 
26
  -v, --version		print version info and exit  
-
 
27
      --debug		turn on shell debugging (set -x)
22
  --no-clean		do not remove created temporary files
28
      --no-clean	do not remove created temporary files
23
  --no-preview		do not preview generated output file
29
      --no-preview	do not preview generated output file
24
  -o, --output=FILE	write output to FILE
30
  -o, --output=FILE	write output to FILE
25
  --pdf			generate PDF output
31
      --pdf		generate PDF output
26
  --title=NAME		use NAME as the title of the document
32
      --title=NAME	use NAME as the title of the document
27
  -v, --version		print version info and exit
-
 
28
  -V, --verbose		report on what is done
33
  -V, --verbose		report on what is done
29
 
34
 
30
Report bugs to <r-bugs@r-project.org>."
35
Report bugs to <r-bugs@r-project.org>."
31
 
36
 
32
start_dir=`pwd`
37
start_dir=`pwd`
Line 55... Line 60...
55
    --no-preview)
60
    --no-preview)
56
      preview=false ;;
61
      preview=false ;;
57
    --pdf)
62
    --pdf)
58
      out_ext="pdf";
63
      out_ext="pdf";
59
      preview=false;
64
      preview=false;
60
      R_RD4DVI=${R_RD4PDF:-"ae,hyper"};
65
      R_RD4DVI=${R_RD4PDF-"ae,hyper"};
61
      R_LATEXCMD=${PDFLATEX:-pdflatex};;
66
      R_LATEXCMD=${PDFLATEX-pdflatex};;
62
    --title=*)
67
    --title=*)
63
      title=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
68
      title=`echo "${1}" | sed -e 's/[^=]*=//'` ;;
64
    -o)
69
    -o)
65
      if test -n "`echo ${2} | sed 's/^-.*//'`"; then      
70
      if test -n "`echo ${2} | sed 's/^-.*//'`"; then      
66
	output="${2}"; shift
71
	output="${2}"; shift
Line 123... Line 128...
123
mkdir ${build_dir}
128
mkdir ${build_dir}
124
 
129
 
125
sed 's/markright{#1}/markboth{#1}{#1}/' \
130
sed 's/markright{#1}/markboth{#1}{#1}/' \
126
  ${R_HOME}/doc/manual/Rd.sty > ${build_dir}/Rd.sty
131
  ${R_HOME}/doc/manual/Rd.sty > ${build_dir}/Rd.sty
127
 
132
 
128
title=${title:-"\\R{} documentation}} \\par\\bigskip{{\\Large of ${subj}"}
133
title=${title-"\\R{} documentation}} \\par\\bigskip{{\\Large of ${subj}"}
129
 
134
 
130
cat > ${build_dir}/Rd2.tex <<EOF
135
cat > ${build_dir}/Rd2.tex <<EOF
131
\\documentclass[${R_PAPERSIZE}paper]{book}
136
\\documentclass[${R_PAPERSIZE}paper]{book}
132
\\usepackage[${R_RD4DVI:-ae}]{Rd}
137
\\usepackage[${R_RD4DVI-ae}]{Rd}
133
\\usepackage{makeidx}
138
\\usepackage{makeidx}
134
\\makeindex
139
\\makeindex
135
\\begin{document}
140
\\begin{document}
136
\\chapter*{}
141
\\chapter*{}
137
\\begin{center}
142
\\begin{center}
Line 152... Line 157...
152
\\end{document}
157
\\end{document}
153
EOF
158
EOF
154
 
159
 
155
echo "Creating ${out_ext} output from LaTeX ..."
160
echo "Creating ${out_ext} output from LaTeX ..."
156
cd ${build_dir}
161
cd ${build_dir}
157
${R_LATEXCMD:-latex} Rd2
162
${R_LATEXCMD-latex} Rd2
158
${R_MAKEINDEXCMD:-makeindex} Rd2
163
${R_MAKEINDEXCMD-makeindex} Rd2
159
${R_LATEXCMD:-latex} Rd2
164
${R_LATEXCMD-latex} Rd2
160
cd ${start_dir}
165
cd ${start_dir}
161
cp ${build_dir}/Rd2.${out_ext} ${output}
166
cp ${build_dir}/Rd2.${out_ext} ${output}
162
if ${clean}; then
167
if ${clean}; then
163
  rm -rf ${build_dir}
168
  rm -rf ${build_dir}
164
else
169
else