Permalink
Browse files

use Rd2roxygen to convert the two manually written Rd files to roxyge…

…n comments, so that all Rd files are automatically generated from roxygen2 now
  • Loading branch information...
1 parent c4edae8 commit c0f7ba9d461a44631976c2c2dc13cee0635640ab @yihui yihui committed Feb 12, 2014
Showing with 200 additions and 98 deletions.
  1. +17 −1 R/shinyui.R
  2. +80 −2 R/tags.R
  3. +65 −48 man/builder.Rd
  4. +38 −47 man/tag.Rd
View
@@ -1,52 +1,68 @@
-
+#' @rdname builder
#' @export
p <- function(...) tags$p(...)
+#' @rdname builder
#' @export
h1 <- function(...) tags$h1(...)
+#' @rdname builder
#' @export
h2 <- function(...) tags$h2(...)
+#' @rdname builder
#' @export
h3 <- function(...) tags$h3(...)
+#' @rdname builder
#' @export
h4 <- function(...) tags$h4(...)
+#' @rdname builder
#' @export
h5 <- function(...) tags$h5(...)
+#' @rdname builder
#' @export
h6 <- function(...) tags$h6(...)
+#' @rdname builder
#' @export
a <- function(...) tags$a(...)
+#' @rdname builder
#' @export
br <- function(...) tags$br(...)
+#' @rdname builder
#' @export
div <- function(...) tags$div(...)
+#' @rdname builder
#' @export
span <- function(...) tags$span(...)
+#' @rdname builder
#' @export
pre <- function(...) tags$pre(...)
+#' @rdname builder
#' @export
code <- function(...) tags$code(...)
+#' @rdname builder
#' @export
img <- function(...) tags$img(...)
+#' @rdname builder
#' @export
strong <- function(...) tags$strong(...)
+#' @rdname builder
#' @export
em <- function(...) tags$em(...)
+#' @rdname builder
#' @export
hr <- function(...) tags$hr(...)
View
@@ -87,38 +87,76 @@ normalizeText <- function(text) {
}
+#' @rdname tag
#' @export
tagList <- function(...) {
lst <- list(...)
class(lst) <- c("shiny.tag.list", "list")
return(lst)
}
+#' @rdname tag
#' @export
tagAppendAttributes <- function(tag, ...) {
tag$attribs <- c(tag$attribs, list(...))
tag
}
+#' @rdname tag
#' @export
tagAppendChild <- function(tag, child) {
tag$children[[length(tag$children)+1]] <- child
tag
}
+#' @rdname tag
#' @export
tagAppendChildren <- function(tag, ..., list = NULL) {
tag$children <- c(tag$children, c(list(...), list))
tag
}
+#' @rdname tag
#' @export
tagSetChildren <- function(tag, ..., list = NULL) {
tag$children <- c(list(...), list)
tag
}
+#' HTML Tag Object
+#'
+#' \code{tag()} creates an HTML tag definition. Note that all of the valid HTML5
+#' tags are already defined in the \code{\link{tags}} environment so these
+#' functions should only be used to generate additional tags.
+#' \code{tagAppendChild()} and \code{tagList()} are for supporting package
+#' authors who wish to create their own sets of tags; see the contents of
+#' bootstrap.R for examples.
+#' @usage tag(`_tag_name`, varArgs)
+#' @param _tag_name HTML tag name
+#' @param varArgs List of attributes and children of the element. Named list
+#' items become attributes, and unnamed list items become children. Valid
+#' children are tags, single-character character vectors (which become text
+#' nodes), and raw HTML (see \code{\link{HTML}}). You can also pass lists that
+#' contain tags, text nodes, and HTML.
+#' @param tag A tag to append child elements to.
+#' @param child A child element to append to a parent tag.
+#' @param ... Unnamed items that comprise this list of tags.
+#' @param list An optional list of elements. Can be used with or instead of the
+#' \code{...} items.
+#' @return An HTML tag object that can be rendered as HTML using
+#' \code{\link{as.character}()}.
#' @export
+#' @examples
+#' tagList(tags$h1("Title"),
+#' tags$h2("Header text"),
+#' tags$p("Text here"))
+#'
+#' # Can also convert a regular list to a tagList (internal data structure isn't
+#' # exactly the same, but when rendered to HTML, the output is the same).
+#' x <- list(tags$h1("Title"),
+#' tags$h2("Header text"),
+#' tags$p("Text here"))
+#' tagList(x)
tag <- function(`_tag_name`, varArgs) {
# Get arg names; if not a named list, use vector of empty strings
varArgsNames <- names(varArgs)
@@ -342,8 +380,48 @@ takeHeads <- function(ui) {
return(list(ui=result, head=headItems))
}
-# environment used to store all available tags
-#' @export
+#' HTML Builder Functions
+#'
+#' Simple functions for constructing HTML documents.
+#'
+#' The \code{tags} environment contains convenience functions for all valid
+#' HTML5 tags. To generate tags that are not part of the HTML5 specification,
+#' you can use the \code{\link{tag}()} function.
+#'
+#' Dedicated functions are available for the most common HTML tags that do not
+#' conflict with common R functions.
+#'
+#' The result from these functions is a tag object, which can be converted using
+#' \code{\link{as.character}()}.
+#'
+#' @name builder
+#' @param ... Attributes and children of the element. Named arguments become
+#' attributes, and positional arguments become children. Valid children are
+#' tags, single-character character vectors (which become text nodes), and raw
+#' HTML (see \code{\link{HTML}}). You can also pass lists that contain tags,
+#' text nodes, and HTML.
+#' @export tags
+#' @examples
+#' doc <- tags$html(
+#' tags$head(
+#' tags$title('My first page')
+#' ),
+#' tags$body(
+#' h1('My first heading'),
+#' p('My first paragraph, with some ',
+#' strong('bold'),
+#' ' text.'),
+#' div(id='myDiv', class='simpleDiv',
+#' 'Here is a div with some attributes.')
+#' )
+#' )
+#' cat(as.character(doc))
+NULL
+
+#' @rdname builder
+#' @format NULL
+#' @docType NULL
+#' @keywords NULL
tags <- list(
a = function(...) tag("a", list(...)),
abbr = function(...) tag("abbr", list(...)),
View
@@ -1,67 +1,83 @@
-\name{builder}
-\alias{p}
+% Generated by roxygen2 (4.0.0): do not edit by hand
+\name{p}
+\alias{a}
+\alias{br}
+\alias{builder}
+\alias{code}
+\alias{div}
+\alias{em}
\alias{h1}
\alias{h2}
\alias{h3}
\alias{h4}
\alias{h5}
\alias{h6}
-\alias{a}
-\alias{br}
-\alias{div}
-\alias{span}
-\alias{pre}
-\alias{code}
+\alias{hr}
\alias{img}
+\alias{p}
+\alias{pre}
+\alias{span}
\alias{strong}
-\alias{em}
-\alias{hr}
\alias{tags}
-
+\title{HTML Builder Functions}
\usage{
- p(...)
- h1(...)
- h2(...)
- h3(...)
- h4(...)
- h5(...)
- h6(...)
- a(...)
- br(...)
- div(...)
- span(...)
- pre(...)
- code(...)
- img(...)
- strong(...)
- em(...)
- hr(...)
-
- tags
-}
+p(...)
-\title{HTML Builder Functions}
+h1(...)
+
+h2(...)
+
+h3(...)
+
+h4(...)
+
+h5(...)
+
+h6(...)
+
+a(...)
+
+br(...)
+
+div(...)
+
+span(...)
+
+pre(...)
+code(...)
+
+img(...)
+
+strong(...)
+
+em(...)
+
+hr(...)
+
+tags
+}
\arguments{
- \item{...}{Attributes and children of the element. Named arguments
- become attributes, and positional arguments become children. Valid
- children are tags, single-character character vectors (which become
- text nodes), and raw HTML (see \code{\link{HTML}}). You can also
- pass lists that contain tags, text nodes, and HTML.}
+ \item{...}{Attributes and children of the element. Named
+ arguments become attributes, and positional arguments
+ become children. Valid children are tags,
+ single-character character vectors (which become text
+ nodes), and raw HTML (see \code{\link{HTML}}). You can
+ also pass lists that contain tags, text nodes, and HTML.}
}
\description{
- Simple functions for constructing HTML documents.
+Simple functions for constructing HTML documents.
}
\details{
- The \code{tags} environment contains convenience functions for all
- valid HTML5 tags. To generate tags that are not part of the HTML5
- specification, you can use the \link{tag} function.
-
- Dedicated functions are available for the most common HTML tags
- that do not conflict with common R functions.
-
- The result from these functions is a tag object, which can be
- converted using \code{as.character}.
+The \code{tags} environment contains convenience functions for all valid
+HTML5 tags. To generate tags that are not part of the HTML5 specification,
+you can use the \code{\link{tag}()} function.
+
+Dedicated functions are available for the most common HTML tags that do not
+conflict with common R functions.
+
+The result from these functions is a tag object, which can be converted using
+\code{\link{as.character}()}.
}
\examples{
doc <- tags$html(
@@ -78,4 +94,5 @@ doc <- tags$html(
)
)
cat(as.character(doc))
-}
+}
+
Oops, something went wrong.

0 comments on commit c0f7ba9

Please sign in to comment.