Skip to content

Commit

Permalink
application dependencies docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jjallaire committed Oct 4, 2013
1 parent 6ea0a0d commit c8f80c8
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 12 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export(accountInfo)
export(accounts)
export(appDependencies)
export(applications)
export(deployApp)
export(removeAccount)
Expand Down
37 changes: 34 additions & 3 deletions R/dependencies.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,38 @@

# detect all package dependencies for an application (recursively discovers
# dependencies for all .R files in the app directory)
appDependencies <- function(appDir) {

#' Detect Application Dependencies
#'
#' Recursively detect all package dependencies for an application. This function
#' parses all .R files in the applicaition directory to determine what packages
#' the application depends on; and for each of those packages what other
#' packages they depend on.
#' @param appDir Directory containing application. Defaults to current working
#' directory.
#' @return Chracter vector with a list of recursive package dependencies for the
#' application.
#' @details
#' Dependencies are determined by parsing application source code and looking
#' for calls to \code{library}, \code{require}, \code{::}, and \code{:::}.
#'
#' If your application has a package dependency that is not detected you can
#' ensure that it is detected by inserting a call to \code{library} or
#' \code{require} with the appropriate package(s).
#'
#' Recursive dependencies are detected by examining the \code{Depends},
#' \code{Imports}, \code{LinkingTo}, and \code{Suggests} fields of the
#' packages immediately dependend on by the application.
#' @examples
#' \dontrun{
#'
#' # dependencies for the app in the current working dir
#' appDependencies()
#'
#' # dependencies for an app in another directory
#' appDependencies("~/projects/shiny/app1")
#' }
#' @seealso \link[shinyapps:shinyappsPackages]{Using Packages with ShinyApps}
#' @export
appDependencies <- function(appDir = getwd()) {

# first get the packages referred to in source code
pkgs <- character()
Expand Down
2 changes: 1 addition & 1 deletion R/deployApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#'
#' For details on options that affect the behavior of \code{deployApp} see the
#' article on \link[shinyapps:shinyappsOptions]{package options}.
#' @param appDir Directory containing application source code. Defaults to
#' @param appDir Directory containing application. Defaults to
#' current working directory.
#' @param appName Name of application (names must be unique with ShinyApps
#' accounts). Defaults to the base name of the specified \code{appDir}.
Expand Down
51 changes: 51 additions & 0 deletions man/appDependencies.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
\name{appDependencies}
\alias{appDependencies}
\title{Detect Application Dependencies}
\usage{
appDependencies(appDir = getwd())
}
\arguments{
\item{appDir}{Directory containing application. Defaults
to current working directory.}
}
\value{
Chracter vector with a list of recursive package
dependencies for the application.
}
\description{
Recursively detect all package dependencies for an
application. This function parses all .R files in the
applicaition directory to determine what packages the
application depends on; and for each of those packages
what other packages they depend on.
}
\details{
Dependencies are determined by parsing application source
code and looking for calls to \code{library},
\code{require}, \code{::}, and \code{:::}.

If your application has a package dependency that is not
detected you can ensure that it is detected by inserting
a call to \code{library} or \code{require} with the
appropriate package(s).

Recursive dependencies are detected by examining the
\code{Depends}, \code{Imports}, \code{LinkingTo}, and
\code{Suggests} fields of the packages immediately
dependend on by the application.
}
\examples{
\dontrun{

# dependencies for the app in the current working dir
appDependencies()

# dependencies for an app in another directory
appDependencies("~/projects/shiny/app1")
}
}
\seealso{
\link[shinyapps:shinyappsPackages]{Using Packages with
ShinyApps}
}

4 changes: 2 additions & 2 deletions man/deployApp.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
quiet = FALSE)
}
\arguments{
\item{appDir}{Directory containing application source
code. Defaults to current working directory.}
\item{appDir}{Directory containing application. Defaults
to current working directory.}

\item{appName}{Name of application (names must be unique
with ShinyApps accounts). Defaults to the base name of
Expand Down
25 changes: 19 additions & 6 deletions man/packages.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,30 @@
\title{Using Packages with ShinyApps}

\description{
description
Applications deployed to ShinyApps can depend on any package available on \href{http://cran.rstudio.com/}{CRAN} as well as any package hosted in a public \href{https://www.github.com}{GitHub} repository.

When an application is \link[shinyapps:deployApp]{deployed} it's source code is scanned for dependencies using the \code{\link{appDependencies}} function. The list of dependencies is sent to the ShinyApps service along with the application source code and these dependencies are then installed alongside the application.
}
\details{
details
\section{CRAN Packages}{
When sastisfying CRAN package dependencies, the ShinyApps service will build the exact versions of packages that were installed on the system from which the application is deployed.
If a locally installed package was not obtained from CRAN (e.g. was installed from R-Forge) and as a result doesn't have a version that matches a version previously published to CRAN then an error will occur. It's therefore important that you run against packages installed directly from CRAN in your local configuration.
}
\examples{
\dontrun{
\section{GitHub Packages}{
It's also possible to depend on packages hosted in public GitHub repositories, so long as they are installed via the \link[devtools:install_github]{install_github} function from the \pkg{devtools} package.

This works because \code{install_github} records the exact Github commit that was installed locally, making it possible to download and install the same source code on the ShinyApps service.

library(plyr)
Note that in order for this to work correctly you need to install the very latest version of \code{devtools} from Github. You can do this as follows:

\preformatted{
library(devtools)
install_github("devtools", "hadley")
}
}

\seealso{
\code{\link{appDependencies}}
}

0 comments on commit c8f80c8

Please sign in to comment.