From a26510b02fefc32e3dea5ca3ed21f2d3be63fe94 Mon Sep 17 00:00:00 2001 From: Barret Schloerke Date: Mon, 26 Aug 2019 15:30:27 -0400 Subject: [PATCH] copy in latest man files from htmltools * fix staticdocs test * remove hasTagAttributes and getTagAttributes from man file --- man/builder.Rd | 92 +++++++++++++++++++++----------- man/knitr_methods_htmltools.Rd | 22 -------- man/tag.Rd | 34 +++++++----- tests/testthat/test-staticdocs.R | 2 +- 4 files changed, 83 insertions(+), 67 deletions(-) delete mode 100644 man/knitr_methods_htmltools.Rd diff --git a/man/builder.Rd b/man/builder.Rd index 461e76104..35537dc25 100644 --- a/man/builder.Rd +++ b/man/builder.Rd @@ -1,67 +1,73 @@ \name{builder} -\alias{a} -\alias{br} \alias{builder} -\alias{code} -\alias{div} -\alias{em} +\alias{tags} +\alias{p} \alias{h1} \alias{h2} \alias{h3} \alias{h4} \alias{h5} \alias{h6} -\alias{hr} -\alias{img} -\alias{p} -\alias{pre} +\alias{a} +\alias{br} +\alias{div} \alias{span} +\alias{pre} +\alias{code} +\alias{img} \alias{strong} -\alias{tags} +\alias{em} +\alias{hr} \title{HTML Builder Functions} \usage{ tags -p(...) +p(..., .noWS = NULL) -h1(...) +h1(..., .noWS = NULL) -h2(...) +h2(..., .noWS = NULL) -h3(...) +h3(..., .noWS = NULL) -h4(...) +h4(..., .noWS = NULL) -h5(...) +h5(..., .noWS = NULL) -h6(...) +h6(..., .noWS = NULL) -a(...) +a(..., .noWS = NULL) -br(...) +br(..., .noWS = NULL) -div(...) +div(..., .noWS = NULL) -span(...) +span(..., .noWS = NULL) -pre(...) +pre(..., .noWS = NULL) -code(...) +code(..., .noWS = NULL) -img(...) +img(..., .noWS = NULL) -strong(...) +strong(..., .noWS = NULL) -em(...) +em(..., .noWS = NULL) -hr(...) +hr(..., .noWS = NULL) } \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.} +tags, single-character character vectors (which become text nodes), raw +HTML (see \code{\link{HTML}}), and \code{html_dependency} objects. You can +also pass lists that contain tags, text nodes, or HTML. To use boolean +attributes, use a named argument with a \code{NA} value. (see example)} + +\item{.noWS}{A character vector used to omit some of the whitespace that +would normally be written around this tag. Valid options include +\code{before}, \code{after}, \code{outside}, \code{after-begin}, and +\code{before-end}. Any number of these options can be specified.} } \description{ Simple functions for constructing HTML documents. @@ -75,7 +81,7 @@ 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[base]{as.character}()}. +\code{\link{as.character}()}. } \examples{ doc <- tags$html( @@ -92,5 +98,27 @@ doc <- tags$html( ) ) cat(as.character(doc)) -} +# create an html5 audio tag with controls. +# controls is a boolean attributes +audio_tag <- tags$audio( + controls = NA, + tags$source( + src = "myfile.wav", + type = "audio/wav" + ) +) +cat(as.character(audio_tag)) + +# suppress the whitespace between tags +oneline <- tags$span( + tags$strong("I'm strong", .noWS="outside") +) +cat(as.character(oneline)) +} +\references{ +\itemize{ + \item W3C html specification about boolean attributes + \url{https://www.w3.org/TR/html5/infrastructure.html#sec-boolean-attributes} + } +} diff --git a/man/knitr_methods_htmltools.Rd b/man/knitr_methods_htmltools.Rd deleted file mode 100644 index 254cfbf41..000000000 --- a/man/knitr_methods_htmltools.Rd +++ /dev/null @@ -1,22 +0,0 @@ -\name{knit_print.html} -\alias{knit_print.html} -\alias{knit_print.shiny.tag} -\alias{knit_print.shiny.tag.list} -\title{Knitr S3 methods} -\usage{ -knit_print.shiny.tag(x, ...) - -knit_print.html(x, ...) - -knit_print.shiny.tag.list(x, ...) -} -\arguments{ -\item{x}{Object to knit_print} - -\item{...}{Additional knit_print arguments} -} -\description{ -These S3 methods are necessary to allow HTML tags to print themselves in -knitr/rmarkdown documents. -} - diff --git a/man/tag.Rd b/man/tag.Rd index 05db94483..ad84e6ccd 100644 --- a/man/tag.Rd +++ b/man/tag.Rd @@ -1,9 +1,9 @@ \name{tag} \alias{tag} +\alias{tagList} \alias{tagAppendAttributes} \alias{tagAppendChild} \alias{tagAppendChildren} -\alias{tagList} \alias{tagSetChildren} \title{HTML Tag Object} \usage{ @@ -17,9 +17,18 @@ tagAppendChildren(tag, ..., list = NULL) tagSetChildren(tag, ..., list = NULL) -tag(`_tag_name`, varArgs) +tag(`_tag_name`, varArgs, .noWS = NULL) } \arguments{ +\item{...}{Unnamed items that comprise this list of tags.} + +\item{tag}{A tag to append child elements to.} + +\item{child}{A child element to append to a parent tag.} + +\item{list}{An optional list of elements. Can be used with or instead of the +\code{...} items.} + \item{_tag_name}{HTML tag name} \item{varArgs}{List of attributes and children of the element. Named list @@ -28,18 +37,14 @@ 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{tag}{A tag to append child elements to.} - -\item{child}{A child element to append to a parent tag.} - -\item{...}{Unnamed items that comprise this list of tags.} - -\item{list}{An optional list of elements. Can be used with or instead of the -\code{...} items.} +\item{.noWS}{Character vector used to omit some of the whitespace that would +normally be written around this tag. Valid options include \code{before}, +\code{after}, \code{outside}, \code{after-begin}, and \code{before-end}. +Any number of these options can be specified.} } \value{ An HTML tag object that can be rendered as HTML using - \code{\link[base]{as.character}()}. + \code{\link{as.character}()}. } \description{ \code{tag()} creates an HTML tag definition. Note that all of the valid HTML5 @@ -60,5 +65,10 @@ x <- list(tags$h1("Title"), tags$h2("Header text"), tags$p("Text here")) tagList(x) -} +# suppress the whitespace between tags +oneline <- tag("span", + tag("strong", "Super strong", .noWS="outside") +) +cat(as.character(oneline)) +} diff --git a/tests/testthat/test-staticdocs.R b/tests/testthat/test-staticdocs.R index 9d080dad7..d7a2cde9d 100644 --- a/tests/testthat/test-staticdocs.R +++ b/tests/testthat/test-staticdocs.R @@ -14,7 +14,7 @@ test_that("All man pages have an entry in staticdocs/index.r", { # Known not to be indexed known_unindexed <- c("shiny-package", "stacktrace", "knitr_methods", - "knitr_methods_htmltools", "deprecatedReactives") + "deprecatedReactives") # Read in topics from a staticdocs/index.r file get_indexed_topics <- function(index_path) {