Skip to content

Commit

Permalink
add docs in rcloud.support (closes #2372 and #2400)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-u committed May 19, 2017
1 parent 0caac73 commit 163d0ec
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 21 deletions.
37 changes: 37 additions & 0 deletions rcloud.support/man/rcloud.home.Rd
@@ -0,0 +1,37 @@
\name{rcloud.home}
\alias{rcloud.home}
\title{
Get path in user's RCloud home directory
}
\description{
\code{rcloud.home} constructs a path based on user's RCloud home
directory. Every user in RCloud has a dedicated RCloud home
directory. That directory is typically different from user's unix home
as that may not even exist depending on the installation. The RCloud
home is also the location of the private library that evey RCloud user
has (\code{rcloud.home("library")}).
}
\usage{
rcloud.home(..., user = if (is.null(.session$exec.usr)) "" else .session$exec.usr)
}
\arguments{
\item{\dots}{additional path components to append to the RCloud home}
\item{user}{user for which the RCloud home is retrieved, defaults to
the current user}
}
%\details{
%}
\value{
String, full path
}
%\references{
%}
\author{
Simon Urbanek
}
\seealso{\code{\link{rcloud.upload.path}}}
\examples{
rcloud.home()
rcloud.home("foo", "my_file.txt")
}
\keyword{manip}
52 changes: 31 additions & 21 deletions rcloud.support/man/rcloud.html.out.Rd
@@ -1,41 +1,51 @@
\name{rcloud.html.out}
\alias{rcloud.html.out}
\alias{rcloud.out}
\title{
Direct output of HTML content to a cell.
Direct output functions in RCloud
}
\description{
\code{rcloud.html.out} passes output directly to a cell such that it
will be interpreted as HTML content.
\code{rcloud.html.out} outputs content as-is directly into the current
cell, typically to create HTML content.

Note: for regular output that is supposed to be quoted use
\code{\link{print}} or \code{\link{cat}} just like in the console.
\code{rcloud.out} evaluates and expression and sends the output into
the R console.
}
\usage{
rcloud.html.out(..., sep = "")
rcloud.out(expr, terminate = "\n")
}
\arguments{
\item{\dots}{content to print. Subsequent arguments will be
concatanated just like in \code{\link{paste}}.
}
\item{sep}{separator to use between arguments}
\item{\dots}{any strings to output}
\item{sep}{string separator}
\item{expr}{expression to evaluate}
\item{terminate}{string to use to terminate the output}
}
\details{
\code{rcloud.html.out} pastes \dots together using separator
\code{sep} and collapsing the result using \code{"\n"} and appends the
resulting string as-is in the cell output. It means that nothing is
escaped such that HTML-tags can be used and will interpreted by the
browser. This allows creating out DOM objects and any other arbitrary
HTML.

\code{rcloud.out} evaluates the expression (in parent frame) and
prints the output (if visible) into the RCloud console. In interactive
use it is mostly equivalent to regular \code{print()}, but in
non-interactive use or special cases (e.g. inside \code{sink()} or
\code{capture.output()}) it makes sure that the output explicitly sent
to the client side as console output.
}
%\details{
%}
\value{
Output content (invisibly)
Both functions return the resulting string invisibly
}
%\references{
%}
\author{
Simon Urbanek
}
\note{
\code{rcloud.html.out} is guaranteed to work only in IDE and view
modes. Modules have to implement \code{"html.out"} OOB handler to
recieve this output and handle it accordingly.
\examples{
rcloud.html.out("<b><font color=red>Bold RED text!</font></b><br>")
rcloud.out(str(iris))
}
%\seealso{
%}
%\examples{
%}
\keyword{manip}
\keyword{print}
74 changes: 74 additions & 0 deletions rcloud.support/man/rcloud.session.info.Rd
@@ -0,0 +1,74 @@
\name{rcloud.session.info}
\alias{rcloud.session.info}
\title{
Get information about an RCloud session
}
\description{
\code{rcloud.session.info} retrieves information about an RCloud session.
}
\usage{
rcloud.session.info(id = .session$sessionID, user = .session$username)
}
\arguments{
\item{id}{session id, defaults to the current session}
\item{user}{username of the user owning the session, defaults to the
current user}
}
\value{
A list with at least the following entries
\item{id}{session ID (typically a GUID)}
\item{host}{name of the host running the session}
\item{script.url}{URL to the script service on that host. Note that
this is only guaranteed to be valid on the RCloud node, generally it
cannot be used from a client}
\item{pid}{process ID of the session}
\item{uname}{unix username}
\item{uid}{unix user id}
\item{gid}{unix group id}
\item{user}{notebook store username}
\item{mode}{type of the session (see Details section)}
\item{start}{timestamp of the session start}
}
%\references{
%}
\author{
Simon Urbanek
}
\details{
Each connection to RCloud creates a session. A session is specific to
a user and running on a specific machine. As such it has all the unix
properties such as pid, uid, gid. In compute separation setup
the current session will be the compute session (although the control
session also exists in parallel).

The mode of the session determines what kind of session was
initialized. This allows the notebook to determine how it is being
run. Althoiugh the mode can be set to anything in the client
the following modes are most often used in regular RCloud:
\itemize{
\item{IDE}{is the mode used by the RCloud UI - both in edit and view
mode}
\item{call}{is used when calling a notebook via the
\code{rcloud.call.notebook} API}
\item{client}{is used by JavaScript clients (mini, shiny etc.)}
\item{script}{is used when running RCloud sclipt on the command
line}
\item{startup}{should never be seen under normal circumstances -
this is the initial mode value before the mode is set by the
connection}
}
}
%\seealso{
%}
\examples{
str(rcloud.session.info())

# use direct output in IDE and RCloud Web otherwise
# so that we see output in both cases
if (rcloud.session.info()$mode == "IDE") {
rcloud.html.out("<h2>Hello, World!</h2>")
} else {
rcloud.web::rcw.result(body="<h2>Hello, World!</h2>")
}
}
\keyword{sysdata}

0 comments on commit 163d0ec

Please sign in to comment.