The R Project SVN R

Rev

Rev 54789 | Rev 56280 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 54789 Rev 54801
Line 1... Line 1...
1
% File src/library/utils/man/sourceutils.Rd
1
% File src/library/utils/man/sourceutils.Rd
2
% Part of the R package, http://www.R-project.org
2
% Part of the R package, http://www.R-project.org
3
% Copyright 2011 R Core Development Team
3
% Copyright 2011 R Core Development Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{sourceutils}
6
\name{sourceutils}
7
\alias{getSrcFilename}
7
\alias{getSrcFilename}
8
\alias{getSrcDirectory}
8
\alias{getSrcDirectory}
9
\alias{getSrcref}
9
\alias{getSrcref}
10
\alias{getSrcLocation}
10
\alias{getSrcLocation}
11
\title{
11
\title{
12
Source reference utilities
12
  Source Reference Utilities
13
}
13
}
14
\description{
14
\description{
15
These functions extract information from source references.
15
  These functions extract information from source references.
16
}
16
}
17
\usage{
17
\usage{
18
getSrcFilename(x, full.names = FALSE, unique = TRUE)
18
getSrcFilename(x, full.names = FALSE, unique = TRUE)
19
getSrcDirectory(x, unique=TRUE) 
19
getSrcDirectory(x, unique=TRUE) 
20
getSrcref(x)
20
getSrcref(x)
21
getSrcLocation(x, which=c("line", "column", "byte", "parse"), 
21
getSrcLocation(x, which=c("line", "column", "byte", "parse"), first=TRUE)
22
                first=TRUE)
-
 
23
}
22
}
24
\arguments{
23
\arguments{
25
  \item{x}{
24
  \item{x}{
26
An object (typically a function) containing source references.
25
    An object (typically a function) containing source references.
27
}
26
  }
28
  \item{full.names}{
27
  \item{full.names}{
29
Whether to include the full path in the filename result.
28
    Whether to include the full path in the filename result.
30
}
29
  }
31
  \item{unique}{
30
  \item{unique}{
32
Whether to list only unique filenames/directories.
31
    Whether to list only unique filenames/directories.
33
}
32
  }
34
  \item{which}{
33
  \item{which}{
35
Which part of a source reference to extract.
34
    Which part of a source reference to extract.
36
}
35
  }
37
  \item{first}{
36
  \item{first}{
38
Whether to show the first (or last) location of the object.
37
    Whether to show the first (or last) location of the object.
39
}
38
  }
40
}
39
}
41
\details{
40
\details{
42
Each statement of a function will have its own source reference if
41
  Each statement of a function will have its own source reference if
43
\code{options(keep.source=TRUE)}.  These functions retrieve all of them.
42
  \code{options(keep.source=TRUE)}.  These functions retrieve all of them.
44
 
43
 
45
The components are as follows:
44
  The components are as follows:
46
\describe{
45
  \describe{
47
\item{line}{The line number where the object starts or ends.}
46
    \item{line}{The line number where the object starts or ends.}
48
\item{column}{The column number where the object starts or ends.}
47
    \item{column}{The column number where the object starts or ends.}
49
\item{byte}{As for \code{"column"}, but counting bytes, which may differ in case
48
    \item{byte}{As for \code{"column"}, but counting bytes, which may
50
of multibyte characters.}
49
      differ in case of multibyte characters.}
51
\item{parse}{As for \code{"line"}, but this ignores \code{#line} directives.}
50
    \item{parse}{As for \code{"line"}, but this ignores \code{#line} directives.}
52
}
51
  }
53
}
52
}
54
\value{
53
\value{
55
\code{getSrcFilename} and \code{getSrcDirectory} return character vectors 
54
  \code{getSrcFilename} and \code{getSrcDirectory} return character vectors 
56
holding the filename/directory.
55
  holding the filename/directory.
57
 
56
 
58
\code{getSrcref} returns a list of \code{"srcref"} objects or \code{NULL} if there are none.
57
  \code{getSrcref} returns a list of \code{"srcref"} objects or
-
 
58
  \code{NULL} if there are none.
59
 
59
 
60
\code{getSrcLocation} returns an integer vector of the requested type of locations
60
  \code{getSrcLocation} returns an integer vector of the requested type
-
 
61
  of locations.
61
}
62
}
62
\seealso{
63
\seealso{
63
\code{\link{srcref}}
64
\code{\link{srcref}}
64
}
65
}
65
\examples{
66
\examples{
66
fn <- function(x) {
67
fn <- function(x) {
67
  x + 1 # A comment, kept as part of the source
68
  x + 1 # A comment, kept as part of the source
68
}			    
69
}			    
69
 
70
 
70
# Show the temporary file directory
71
# Show the temporary file directory
71
# where the example was saved
72
# where the example was saved
72
 
73
 
73
getSrcDirectory(fn)  
74
getSrcDirectory(fn)  
74
getSrcLocation(fn, "line")
75
getSrcLocation(fn, "line")
75
}
76
}
76
\keyword{ utilities }
77
\keyword{ utilities }