diff --git a/rkward/rbackend/rpackages/rkward/DESCRIPTION b/rkward/rbackend/rpackages/rkward/DESCRIPTION index 1c126bb2..bb558956 100755 --- a/rkward/rbackend/rpackages/rkward/DESCRIPTION +++ b/rkward/rbackend/rpackages/rkward/DESCRIPTION @@ -1,44 +1,44 @@ Package: rkward Type: Package Title: Provides functions related to the RKWard GUI Description: This package contains functions which are useful in combination with the RKWard GUI. Many of these functions only needed for the internal communication between RKWard and R, but some are also useful in user scripts. Author: Thomas Friedrichsmeier and the RKWard Team Maintainer: RKWard-devel mailing list Depends: R (>= 2.9.0),methods URL: https://rkward.kde.org BugReports: https://rkward.kde.org/Bugs License: GPL (>= 2) Encoding: UTF-8 LazyLoad: yes Authors@R: c(person(given="Thomas", family="Friedrichsmeier", email="thomas.friedrichsmeier@ruhr-uni-bochum.de", role=c("aut")), person(given="the RKWard team", email="rkward-devel@kde.org", role=c("cre","ctb"))) Version: 0.7.1 Date: 2018-10-11 RoxygenNote: 6.1.0 Collate: 'base_overrides.R' 'internal.R' 'internal_debugger.R' 'internal_graphics.R' 'internal_help.R' 'public_graphics.R' 'rk.KDE_GUI-functions.R' - 'rk.check_for_pandoc.R' + 'rk.check.for.pandoc.R' 'rk.demo.R' 'rk.edit-functions.R' 'rk.filename-functions.R' 'rk.label-functions.R' 'rk.plugin-functions.R' 'rk.print-functions.R' 'rk.replace.function.R' 'rk.sessionInfo.R' 'rk.sync-functions.R' 'rk.utility-functions.R' 'rk.workspace-functions.R' 'rkward-package.R' 'ver.R' diff --git a/rkward/rbackend/rpackages/rkward/R/rk.check.for.pandoc.R b/rkward/rbackend/rpackages/rkward/R/rk.check.for.pandoc.R index ccc7a345..f4bfe17f 100644 --- a/rkward/rbackend/rpackages/rkward/R/rk.check.for.pandoc.R +++ b/rkward/rbackend/rpackages/rkward/R/rk.check.for.pandoc.R @@ -1,27 +1,43 @@ #' Check for pandoc installation and its features #' #' This function looks for a pandoc installation and if found, gathers information -#' on its path, supported output formats, and the version number. It has no parameters. +#' on its path, supported output formats, and the version number. #' +#' @param stop_if_missing Logical, whether an error should be thrown if either pandoc can't be found at all +#' or a requested output format is not supported. +#' @param output_format A character string, name of a requested output format. If not \code{NA}, +#' the function will check if the format is supported and return a boolean value. #' @return A named list with at least the boolean element \code{available}, and if #' that is \code{TRUE}, also the character vectors \code{path}, \code{output_formats}, and \code{version}. #' @author Meik Michalke \email{rkward-devel@@kde.org} #' @seealso \code{\link{rk.sessionInfo}} #' @keywords utilities misc #' @export #' @rdname rk.check.for.pandoc #' @examples #' #' rk.check.for.pandoc() -"rk.check.for.pandoc" <- function(){ +"rk.check.for.pandoc" <- function(stop_if_missing=FALSE, output_format=NA){ pandoc <- list(available=FALSE) pandoc_path <- Sys.which("pandoc")[["pandoc"]] if(!"" %in% pandoc_path){ pandoc[["path"]] <- pandoc_path pandoc[["available"]] <- TRUE pandoc[["output_formats"]] <- system("pandoc --list-output-formats", intern=TRUE) pandoc[["version"]] <- gsub("[[:space:]]*pandoc[[:space:]]*", "", system("pandoc --version", intern=TRUE)[1]) + + if(!is.na(output_format)){ + pandoc <- output_format %in% pandoc[["output_formats"]] + if(all(isTRUE(stop_if_missing), !isTRUE(pandoc))){ + stop(simpleError( + paste0("The requested output format '", output_format, "' is not supported by your pandoc installation.") + )) + } else {} + } else {} + } else if(isTRUE(stop_if_missing)){ + stop(simpleError("'pandoc' was not found, please check your installation!")) } else {} + return(pandoc) } diff --git a/rkward/rbackend/rpackages/rkward/man/rk.check.for.pandoc.Rd b/rkward/rbackend/rpackages/rkward/man/rk.check.for.pandoc.Rd index 5a061c53..043cea2e 100644 --- a/rkward/rbackend/rpackages/rkward/man/rk.check.for.pandoc.Rd +++ b/rkward/rbackend/rpackages/rkward/man/rk.check.for.pandoc.Rd @@ -1,29 +1,38 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rk.check_for_pandoc.R +% Please edit documentation in R/rk.check.for.pandoc.R \name{rk.check.for.pandoc} \alias{rk.check.for.pandoc} \title{Check for pandoc installation and its features} \usage{ -rk.check.for.pandoc() +rk.check.for.pandoc(stop_if_missing = FALSE, output_format = NA) +} +\arguments{ +\item{stop_if_missing}{Logical, + whether an error should be thrown if either pandoc can't be found at all +or a requested output format is not supported.} + +\item{output_format}{A character string, + name of a requested output format. If not \code{NA}, +the function will check if the format is supported and return a boolean value.} } \value{ A named list with at least the boolean element \code{available}, and if that is \code{TRUE}, also the character vectors \code{path}, \code{output_formats}, and \code{version}. } \description{ This function looks for a pandoc installation and if found, gathers information -on its path, supported output formats, and the version number. It has no parameters. +on its path, supported output formats, and the version number. } \examples{ rk.check.for.pandoc() } \seealso{ \code{\link{rk.sessionInfo}} } \author{ Meik Michalke \email{rkward-devel@kde.org} } \keyword{misc} \keyword{utilities}