satisfy R CMD CHECK: validate srcfile, use with(tags rather than withTags

This commit is contained in:
Jonathan McPherson
2014-01-07 12:51:03 -08:00
parent 026cda0071
commit 3d031265d1
2 changed files with 17 additions and 6 deletions

View File

@@ -1,3 +1,4 @@
# Given the name of a license, return the appropriate link HTML for the
# license, which may just be the name of the license if the name is
# unrecognized.
@@ -27,7 +28,7 @@ licenseLink <- function(licenseName) {
# document.
showcaseHead <- function() {
mdfile <- file.path.ci(getwd(), 'Readme.md')
withTags(tagList(
with(tags, tagList(
script(src="shared/highlight/highlight.pack.js"),
script(src="shared/showdown/compressed/showdown.js"),
script(src="shared/jquery-ui/jquery-ui-min.js"),
@@ -50,7 +51,7 @@ showcaseHead <- function() {
appMetadata <- function(desc) {
cols <- colnames(desc)
if ("Title" %in% cols)
withTags(h4(class="muted shiny-showcase-apptitle", desc[1,"Title"],
with(tags, h4(class="muted shiny-showcase-apptitle", desc[1,"Title"],
if ("Author" %in% cols) small(
br(), "by",
if ("AuthorUrl" %in% cols)
@@ -71,7 +72,7 @@ appMetadata <- function(desc) {
# showcase mode.
showcaseCodeTabs <- function(codeLicense) {
rFiles <- list.files(pattern = "\\.R$")
withTags(div(id="showcase-code-tabs",
with(tags, div(id="showcase-code-tabs",
button(id="showcase-code-position-toggle",
class="btn btn-default btn-small",
onclick="toggleCodePosition()",
@@ -111,7 +112,7 @@ showcaseAppInfo <- function() {
if (hasDesc) {
desc <- read.dcf(descfile)
}
withTags(
with(tags,
div(class="container-fluid shiny-code-container well",
id="showcase-well",
div(class="row-fluid",
@@ -133,7 +134,7 @@ showcaseAppInfo <- function() {
# Returns the body of the showcase document, given the HTML it should wrap.
showcaseBody <- function(htmlBody) {
withTags(tagList(
with(tags, tagList(
table(id="showcase-app-code",
tr(td(id="showcase-app-container",
class="showcase-app-container-expanded",

View File

@@ -448,6 +448,16 @@ showcaseModeOfReq <- function(req) {
showcaseModeOfQuerystring(req$QUERY_STRING)
}
# Returns (just) the filename containing the given source reference, or an
# empty string if the source reference doesn't include file information.
srcFileOfRef <- function(srcref) {
basename((attr(srcref, "srcfile"))$filename)
fileEnv <- attr(srcref, "srcfile")
# The 'srcfile' attribute should be a non-null environment containing the
# variable 'filename', which gives the full path to the source file.
if (!is.null(fileEnv) &&
is.environment(fileEnv) &&
exists("filename", where = fileEnv))
basename(fileEnv[["filename"]])
else
""
}