Skip to content

Commit c4dff3c

Browse files
author
Kirill Müller
committed
Revert "ignore documentation"
This reverts commit f94a435.
1 parent f94a435 commit c4dff3c

File tree

5 files changed

+193
-1
lines changed

5 files changed

+193
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/man
21
.Rproj.user
32
.Rhistory
43
.RData

man/criteria.Rd

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
% Generated by roxygen2 (4.1.1.9001): do not edit by hand
2+
% Please edit documentation in R/has-file.R
3+
\docType{data}
4+
\name{criteria}
5+
\alias{criteria}
6+
\alias{is_r_package}
7+
\alias{is_rstudio_project}
8+
\title{Prespecified criteria}
9+
\format{\preformatted{List of 2
10+
$ is_rstudio_project: chr "Root criterion: Contains a file matching '^.*\\\\.Rproj$' with contents matching '^Version: ' in the first 1 lines"
11+
$ is_r_package : chr "Root criterion: Contains a file 'DESCRIPTION' with contents matching '^Package: '"
12+
}}
13+
\usage{
14+
criteria
15+
16+
is_rstudio_project
17+
18+
is_r_package
19+
}
20+
\description{
21+
This is a collection of commonly used root criteria.
22+
}
23+
\details{
24+
\code{is_rstudio_project} looks for a file with extension \code{.Rproj}.
25+
26+
\code{is_r_package} looks for a \code{DESCRIPTION} file.
27+
}
28+
\keyword{datasets}
29+

man/find_root.Rd

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
% Generated by roxygen2 (4.1.1.9001): do not edit by hand
2+
% Please edit documentation in R/root.R
3+
\name{find_root}
4+
\alias{find_root}
5+
\title{Find the root of a directory hierarchy}
6+
\usage{
7+
find_root(criterion, path = ".")
8+
}
9+
\arguments{
10+
\item{criterion}{A criterion, will be coerced using
11+
\code{\link{as.root_criterion}}}
12+
13+
\item{path}{The start directory}
14+
}
15+
\value{
16+
The normalized path of the root as specified by the search criterion.
17+
Throws an error if no root is found
18+
}
19+
\description{
20+
A \emph{root} is defined as a directory that contains a regular file
21+
whose name matches a given pattern and which optionally contains a given text.
22+
The search for a root starts at a given directory (the working directory
23+
by default), and proceeds up the directory hierarchy.
24+
}
25+
\details{
26+
Starting from the working directory, the \code{find_root} function searches
27+
for the root.
28+
If a root is found, the \code{...} arguments are used to construct a path;
29+
thus, if no extra arguments are given, the root is returned.
30+
If no root is found, an error is thrown.
31+
}
32+
\examples{
33+
\dontrun{
34+
find_root(glob2rx("DESCRIPTION"), "^Package: ")
35+
}
36+
}
37+
\seealso{
38+
\code{\link[utils]{glob2rx}} \code{\link{file.path}}
39+
}
40+

man/find_root_file.Rd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
% Generated by roxygen2 (4.1.1.9001): do not edit by hand
2+
% Please edit documentation in R/file.R, R/rrmake.R
3+
\name{find_root_file}
4+
\alias{find_package_root_file}
5+
\alias{find_root_file}
6+
\alias{find_rstudio_root_file}
7+
\alias{make_find_root_file}
8+
\alias{make_fix_root_file}
9+
\title{File paths relative to the root of a directory hierarchy}
10+
\usage{
11+
find_root_file(..., criterion, path = ".")
12+
13+
make_find_root_file(criterion)
14+
15+
make_fix_root_file(criterion)
16+
17+
find_rstudio_root_file(..., path = ".")
18+
19+
find_package_root_file(..., path = ".")
20+
}
21+
\arguments{
22+
\item{...}{Additional arguments passed to \code{\link{file.path}}}
23+
24+
\item{criterion}{A criterion, will be coerced using
25+
\code{\link{as.root_criterion}}}
26+
27+
\item{path}{The start directory}
28+
}
29+
\value{
30+
The normalized path of the root as specified by the search criteria.
31+
Throws an error if no root is found
32+
}
33+
\description{
34+
Append an arbitrary number of path components to the root using
35+
\code{\link[base]{file.path}}.
36+
}
37+
\details{
38+
The \code{find_root_file} function is a simple wrapper around
39+
\code{\link{find_root}} that
40+
appends an arbitrary number of path components to the root using
41+
\code{\link[base]{file.path}}.
42+
The function \code{make_find_root_file} can be used to create shorthand functions
43+
such as \code{find_rstudio_root_file} and \code{find_package_root_file}.
44+
In many cases, the function \code{make_fix_root_file} is even more useful:
45+
It creates a shorthand function that is tied to a fixed root (as opposed to
46+
\code{make_find_root_file} which creates a function that will look for the
47+
root every time it is called).
48+
}
49+
\examples{
50+
\dontrun{
51+
find_package_root_file("tests", "testthat.R")
52+
make_find_root_file(glob2rx("DESCRIPTION"), "^Package: ")
53+
make_fix_root_file(glob2rx("DESCRIPTION"), "^Package: ")
54+
}
55+
}
56+
\seealso{
57+
\code{\link{find_root}} \code{\link[utils]{glob2rx}} \code{\link[base]{file.path}}
58+
}
59+

man/root_criterion.Rd

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
% Generated by roxygen2 (4.1.1.9001): do not edit by hand
2+
% Please edit documentation in R/criterion.R, R/has-file.R
3+
\name{root_criterion}
4+
\alias{as.root_criterion}
5+
\alias{as.root_criterion.character}
6+
\alias{as.root_criterion.root_criterion}
7+
\alias{has_file}
8+
\alias{has_file_pattern}
9+
\alias{is.root_criterion}
10+
\alias{root_criterion}
11+
\title{Is a directory the project root?}
12+
\usage{
13+
root_criterion(testfun, desc)
14+
15+
is.root_criterion(x)
16+
17+
as.root_criterion(x)
18+
19+
\method{as.root_criterion}{character}(x)
20+
21+
\method{as.root_criterion}{root_criterion}(x)
22+
23+
has_file(filepath, contents = NULL, n = -1L)
24+
25+
has_file_pattern(pattern, contents = NULL, n = -1L)
26+
}
27+
\arguments{
28+
\item{testfun}{A function with one parameter that returns \code{TRUE}
29+
if the directory specified by this parameter is the project root,
30+
and \code{FALSE} otherwise}
31+
32+
\item{desc}{A textual description of the test criterion}
33+
34+
\item{x}{An object}
35+
36+
\item{filepath}{File path (can contain directories)}
37+
38+
\item{contents}{Regular expression to match the file contents}
39+
40+
\item{n}{integer. The (maximal) number of lines to
41+
read. Negative values indicate that one should read up to the end of
42+
input on the connection.}
43+
44+
\item{pattern}{Regular expression to match the file name}
45+
}
46+
\description{
47+
Objects of the \code{root_criterion} class decide if a
48+
given directory is a project root.
49+
}
50+
\details{
51+
Construct criteria using \code{root_criterion} in a very general fashion
52+
by specifying a function with a \code{path} argument, and a description.
53+
54+
The \code{as.root_criterion} function accepts objects of class
55+
\code{root_criterion}, and character values; the latter will be
56+
converted to criteria using \code{has_file}.
57+
58+
The \code{has_file} function constructs a criterion that checks for the
59+
existence of a specific file (which itself can be in a subdirectory of the
60+
root) with specific contents.
61+
62+
The \code{has_file_pattern} function constructs a criterion that checks for the
63+
existence of a file that matches a pattern, with specific contents.
64+
}
65+

0 commit comments

Comments
 (0)