The R Project SVN R

Rev

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

Rev 46962 Rev 46993
Line 5... Line 5...
5
## Examples:
5
## Examples:
6
##  R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd
6
##  R CMD Rd2dvi /path/to/Rsrc/src/library/base/man/Normal.Rd
7
##  R CMD Rd2dvi `grep -l "\\keyword{distr" \
7
##  R CMD Rd2dvi `grep -l "\\keyword{distr" \
8
##                  /path/to/Rsrc/src/library/stats/man/*.Rd | sort | uniq`
8
##                  /path/to/Rsrc/src/library/stats/man/*.Rd | sort | uniq`
9
 
9
 
10
revision='$Rev: 46962 $'
10
revision='$Rev: 46993 $'
11
version=`set - ${revision}; echo ${2}`
11
version=`set - ${revision}; echo ${2}`
12
version="Rd2dvi ${version}
12
version="Rd2dvi ${version}
13
 
13
 
14
Copyright (C) 2000-2008 The R Core Development Team.
14
Copyright (C) 2000-2008 The R Core Development Team.
15
This is free software; see the GNU General Public License version 2
15
This is free software; see the GNU General Public License version 2
16
or later for copying conditions.  There is NO warranty." 
16
or later for copying conditions.  There is NO warranty."
17
 
17
 
18
usage="Usage: R CMD Rd2dvi [options] files
18
usage="Usage: R CMD Rd2dvi [options] files
19
 
19
 
20
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
21
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
Line 97... Line 97...
97
      if test "${preview}" != "false"; then
97
      if test "${preview}" != "false"; then
98
	if test -n "${R_PDFVIEWER}"; then
98
	if test -n "${R_PDFVIEWER}"; then
99
	    preview=${R_PDFVIEWER}
99
	    preview=${R_PDFVIEWER}
100
	elif test "${R_OSTYPE}" = "windows"; then
100
	elif test "${R_OSTYPE}" = "windows"; then
101
	    preview=open
101
	    preview=open
102
        else
102
	else
103
	    preview=false
103
	    preview=false
104
	fi
104
	fi
105
      fi
105
      fi
106
      R_RD4DVI=${R_RD4PDF-"times,hyper"}
106
      R_RD4DVI=${R_RD4PDF-"times,hyper"}
107
      R_LATEXCMD="${R_PDFLATEXCMD}"
107
      R_LATEXCMD="${R_PDFLATEXCMD}"
108
      ;;
108
      ;;
109
    --title=*)
109
    --title=*)
110
      title=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;
110
      title=`echo "${1}" | ${SED} -e 's/[^=]*=//'` ;;
111
    -o)
111
    -o)
112
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then      
112
      if test -n "`echo ${2} | ${SED} 's/^-.*//'`"; then
113
	output="${2}"; shift
113
	output="${2}"; shift
114
      else
114
      else
115
	echo "ERROR: option '${1}' requires an argument"
115
	echo "ERROR: option '${1}' requires an argument"
116
	exit 1
116
	exit 1
117
      fi
117
      fi
Line 163... Line 163...
163
  shift
163
  shift
164
 
164
 
165
  if test -d ${1}; then
165
  if test -d ${1}; then
166
    if ${only_meta}; then
166
    if ${only_meta}; then
167
      files=
167
      files=
168
    else  
168
    else
169
      files=`ls ${1}/*.[Rr]d`
169
      files=`ls ${1}/*.[Rr]d`
170
      if test -d ${1}/${OSdir}; then
170
      if test -d ${1}/${OSdir}; then
171
        files="${files} `ls ${1}/${OSdir}/*.[Rr]d`"
171
	files="${files} `ls ${1}/${OSdir}/*.[Rr]d`"
172
      fi
172
      fi
173
      files=`LC_ALL=C ${echo} ${files} | sort`
173
      files=`LC_ALL=C ${echo} ${files} | sort`
174
    fi
174
    fi
175
  else
175
  else
176
    files="${@}"
176
    files="${@}"
Line 188... Line 188...
188
Rd_DESCRIPTION_to_LaTeX () {
188
Rd_DESCRIPTION_to_LaTeX () {
189
  ## Typeset the contents of a DESCRIPTION file in a LaTeX description
189
  ## Typeset the contents of a DESCRIPTION file in a LaTeX description
190
  ## list.
190
  ## list.
191
  ## Usage:
191
  ## Usage:
192
  ##   Rd_DESCRIPTION_to_LaTeX FILE
192
  ##   Rd_DESCRIPTION_to_LaTeX FILE
193
  
193
 
194
  fields=`${SED} '/^[ 	]/d; s/^\([^:]*\):.*$/\1/' $1`
194
  fields=`${SED} '/^[	]/d; s/^\([^:]*\):.*$/\1/' $1`
195
  ${echo} "\\begin{description}"
195
  ${echo} "\\begin{description}"
196
  ${echo} "\\raggedright{}"
196
  ${echo} "\\raggedright{}"
197
  ## this throws warnings on Solaris sed as input is missing newline
197
  ## this throws warnings on Solaris sed as input is missing newline
198
  for f in `${echo} "${fields}" | ${SED} '/Package/d; /Bundle/d;'`; do
198
  for f in `${echo} "${fields}" | ${SED} '/Package/d; /Bundle/d;'`; do
199
    text=`get_dcf_field ${f} ${1} | \
199
    text=`get_dcf_field ${f} ${1} | \
200
      tr '\n' ' ' | \
200
      tr '\n' ' ' | \
201
      ${SED} "s/\"\([^\"]*\)\"/\\\`\\\`\\1''/g
201
      ${SED} "s/\"\([^\"]*\)\"/\\\`\\\`\\1''/g
202
                  s/\\\\\\\\/\\\\\\\\textbackslash /g
202
		  s/\\\\\\\\/\\\\\\\\textbackslash /g
203
                  s/{/\\\\\\\\{/g
203
		  s/{/\\\\\\\\{/g
204
		  s/}/\\\\\\\\}/g" 2>/dev/null`
204
		  s/}/\\\\\\\\}/g" 2>/dev/null`
205
    ff=`echo ${f} | ${SED} s/_/\\\\\\\\_/g`
205
    ff=`echo ${f} | ${SED} s/_/\\\\\\\\_/g`
206
    ${echo} "\\item[${ff}] \\AsIs{${text}}"
206
    ${echo} "\\item[${ff}] \\AsIs{${text}}"
207
  done
207
  done
208
  ${echo} "\\end{description}"
208
  ${echo} "\\end{description}"
Line 235... Line 235...
235
    is_base_package=yes
235
    is_base_package=yes
236
    echo "Hmm ... looks like a package from the R distribution"
236
    echo "Hmm ... looks like a package from the R distribution"
237
    package_name=`get_dcf_field Package "${1}/DESCRIPTION.in"`
237
    package_name=`get_dcf_field Package "${1}/DESCRIPTION.in"`
238
    title=${title-"Package \`${package_name}'"}
238
    title=${title-"Package \`${package_name}'"}
239
    dir=${1}/man
239
    dir=${1}/man
240
    test -z "${output}" && output="`basename ${1}`.${out_ext}"    
240
    test -z "${output}" && output="`basename ${1}`.${out_ext}"
-
 
241
    ## base package has things like %in% that sometimes cause trouble
-
 
242
    test ${package_name} == "base" && index=false
241
  else
243
  else
242
    if test -d ${1}/man; then
244
    if test -d ${1}/man; then
243
      dir=${1}/man
245
      dir=${1}/man
244
    else
246
    else
245
      dir=${1}
247
      dir=${1}
Line 268... Line 270...
268
title=${title-$title1}
270
title=${title-$title1}
269
 
271
 
270
if test "${enc}"="unknown"; then
272
if test "${enc}"="unknown"; then
271
  if test -n "$pkg_enc"; then
273
  if test -n "$pkg_enc"; then
272
    enc=${pkg_enc}
274
    enc=${pkg_enc}
273
    ${verbose} "using package encoding ${enc}" 
275
    ${verbose} "using package encoding ${enc}"
274
  fi
276
  fi
275
fi
277
fi
276
 
278
 
277
## Prepare for building the documentation.
279
## Prepare for building the documentation.
278
if test -z "${output}"; then
280
if test -z "${output}"; then
Line 339... Line 341...
339
  cat >> ${build_dir}/Rd2.tex <<EOF
341
  cat >> ${build_dir}/Rd2.tex <<EOF
340
\\vfill\\vfill
342
\\vfill\\vfill
341
\\end{titlepage}
343
\\end{titlepage}
342
EOF
344
EOF
343
fi
345
fi
344
  
346
 
345
## Rd2.tex part 2: body
347
## Rd2.tex part 2: body
346
if test "${is_bundle}" = no; then
348
if test "${is_bundle}" = no; then
347
  ${only_meta} || ${echo} ${toc} >> ${build_dir}/Rd2.tex
349
  ${only_meta} || ${echo} ${toc} >> ${build_dir}/Rd2.tex
348
  Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${dir-${@}}
350
  Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${dir-${@}}
349
else
351
else
Line 357... Line 359...
357
  for p in ${bundle_pkgs}; do
359
  for p in ${bundle_pkgs}; do
358
    ${echo} "Bundle package: '${p}'"
360
    ${echo} "Bundle package: '${p}'"
359
    ${echo} "\\chapter{Package \`${p}'}" >> ${build_dir}/Rd2.tex
361
    ${echo} "\\chapter{Package \`${p}'}" >> ${build_dir}/Rd2.tex
360
    if test -f ${1}/${p}/DESCRIPTION.in; then
362
    if test -f ${1}/${p}/DESCRIPTION.in; then
361
      Rd_DESCRIPTION_to_LaTeX ${1}/${p}/DESCRIPTION.in \
363
      Rd_DESCRIPTION_to_LaTeX ${1}/${p}/DESCRIPTION.in \
362
        >> ${build_dir}/Rd2.tex
364
	>> ${build_dir}/Rd2.tex
363
    fi
365
    fi
364
    Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${1}/${p}/man
366
    Rdconv_dir_or_files_to_LaTeX ${build_dir}/Rd2.tex ${1}/${p}/man
365
    ${echo} "\\clearpage{}" >> ${build_dir}/Rd2.tex
367
    ${echo} "\\clearpage{}" >> ${build_dir}/Rd2.tex
366
  done
368
  done
367
  ${echo} "\\cleardoublepage{}" >> ${build_dir}/Rd2.tex
369
  ${echo} "\\cleardoublepage{}" >> ${build_dir}/Rd2.tex