Browse Source

forgot CRAN & Travis can't do headless browsing for widget testing

master
Bob Rudis 6 years ago
parent
commit
cf1a92172a
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 16
      R/xmltreeview.R
  2. 12
      R/xmlview.R
  3. 13
      inst/examples/examples-xml_tree_view.R
  4. 11
      inst/examples/rss-example.R
  5. 2
      man/xml_tree_view.Rd
  6. 11
      man/xml_view.Rd

16
R/xmltreeview.R

@ -19,7 +19,21 @@
#' or used in a browser context vs an IDE viewer context.
#' @export
#' @references \href{https://github.com/juliangruber/xml-viewer}{xml-viewer}
#' @example inst/examples/examples-xml_tree_view.R
#' @examples \dontrun{
#' library(htmltidy)
#'
#' # from ?xml2::read_xml
#' cd <- xml2::read_xml("http://www.xmlfiles.com/examples/cd_catalog.xml")
#'
#' xml_tree_view(cd)
#'
#' htmltools::browsable(
#' htmltools::tagList(
#' xml_tree_view(cd, width = "100%", height = "300px"),
#' xml_view(cd)
#' )
#' )
#' }
xml_tree_view <- function(doc=NULL, scroll=FALSE,
elementId=NULL, width="100%", height=NULL) {

12
R/xmlview.R

@ -27,7 +27,7 @@
#' @export
#' @references \href{https://highlightjs.org/}{highlight.js},
#' \href{http://www.eslinstructor.net/vkbeautify/}{vkbeautify}
#' @examples
#' @examples \dontrun{
#' library(xml2)
#'
#' # plain text
@ -52,6 +52,16 @@
#' # filter + apply an initial XPath query string
#' xml_view(read_xml(system.file("extdata/dwml.xml", package="xmlview")),
#' add_filter=TRUE, apply_xpath=".//temperature")
#'
#' doc <- read_xml("http://www.npr.org/rss/rss.php?id=1001")
#'
#' str(doc)
#'
#' xml_view(doc, add_filter=TRUE)
#' xml2::xml_find_all(doc, './/dc:creator', ns=xml2::xml_ns(doc))
#'
#' xml_text(xml2::xml_find_all(doc, './/link[contains(., "soccer")]', ns=xml2::xml_ns(doc)))
#' }
xml_view <- function(doc, style="default", scroll=FALSE, add_filter=FALSE,
apply_xpath=NULL, elementId=NULL,
width="100%", height=NULL) {

13
inst/examples/examples-xml_tree_view.R

@ -1,13 +0,0 @@
library(htmltidy)
# from ?xml2::read_xml
cd <- xml2::read_xml("http://www.xmlfiles.com/examples/cd_catalog.xml")
xml_tree_view(cd)
htmltools::browsable(
htmltools::tagList(
xml_tree_view(cd, width = "100%", height = "300px"),
xml_view(cd)
)
)

11
inst/examples/rss-example.R

@ -1,11 +0,0 @@
library(xml2)
doc <- read_xml("http://www.npr.org/rss/rss.php?id=1001")
str(doc)
xml_view(doc, add_filter=TRUE)
xml2::xml_find_all(doc, './/dc:creator', ns=xml2::xml_ns(doc))
xml_text(xml2::xml_find_all(doc, './/link[contains(., "soccer")]', ns=xml2::xml_ns(doc)))

2
man/xml_tree_view.Rd

@ -38,6 +38,7 @@ Large HTML or XML content may take some time to render properly. It is suggested
or used in a browser context vs an IDE viewer context.
}
\examples{
\dontrun{
library(htmltidy)
# from ?xml2::read_xml
@ -52,6 +53,7 @@ htmltools::browsable(
)
)
}
}
\references{
\href{https://github.com/juliangruber/xml-viewer}{xml-viewer}
}

11
man/xml_view.Rd

@ -48,6 +48,7 @@ Large HTML or XML content may take some time to render properly. It is suggested
or used in a browser context vs an IDE viewer context.
}
\examples{
\dontrun{
library(xml2)
# plain text
@ -72,6 +73,16 @@ xml_view(read_xml(system.file("extdata/input.xml", package="htmltidy")),
# filter + apply an initial XPath query string
xml_view(read_xml(system.file("extdata/dwml.xml", package="xmlview")),
add_filter=TRUE, apply_xpath=".//temperature")
doc <- read_xml("http://www.npr.org/rss/rss.php?id=1001")
str(doc)
xml_view(doc, add_filter=TRUE)
xml2::xml_find_all(doc, './/dc:creator', ns=xml2::xml_ns(doc))
xml_text(xml2::xml_find_all(doc, './/link[contains(., "soccer")]', ns=xml2::xml_ns(doc)))
}
}
\references{
\href{https://highlightjs.org/}{highlight.js},

Loading…
Cancel
Save