[rkward-cvs] SF.net SVN: rkward:[4293] trunk/rkward/rkward/rbackend/rpackages/rkward/R/ rk.print-functions.R

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sat Aug 25 19:22:34 UTC 2012


Revision: 4293
          http://rkward.svn.sourceforge.net/rkward/?rev=4293&view=rev
Author:   tfry
Date:     2012-08-25 19:22:34 +0000 (Sat, 25 Aug 2012)
Log Message:
-----------
A different approach to handling TOC in the testing environment.
Not really much cleaner, but it puts the testing environment in control, which will also allow writing a test specifically for the TOC (with options(.rk.suppress.toc=FALSE))

Modified Paths:
--------------
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R	2012-08-25 19:20:25 UTC (rev 4292)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/rk.print-functions.R	2012-08-25 19:22:34 UTC (rev 4293)
@@ -108,23 +108,21 @@
 
 	# give header a name to be able to set anchors
 	# it's just a time string down to the fraction of a second: yyyy-mm-dd HH:MM:SS.ssssss
-	# but to enable proper plugin tests, first check if we're running in a test environment
-	if(tryCatch(
-		is.environment(rkwardtests::.rktest.tmp.storage) && exists(".rk.date", envir=rkwardtests::.rktest.tmp.storage, inherits=FALSE),
-		error=function(e) return(FALSE))){
-		header.id <- header.title <- "test"
-	} else {
+	if (!isTRUE (options (".rk.suppress.toc")[[1]])) {	# disabled during plugin automated testing
 		header.id <- format(Sys.time(), "%Y-%m-%d_%H:%M:%OS6")
 		header.title <- format(Sys.time(), "%Y-%m-%d %H:%M:%S")
+		# add 'id', 'name' and 'title' attributes to the header
+		cat ("<h", level, "><a id=\"", header.id,"\" name=\"", header.id,"n\" title=\"", header.title,"\">", title, "</a></h", level, ">\n", sep="")
+		# if 'toc' is true, also add a javascript function call to add this header to the TOC menu
+		# the function addToTOC() will be defined in the document head
+		# see rk.set.output.html.file() in rk.filename-functions.R
+		if (isTRUE(toc) || (is.null(toc) && level <= 4)){
+			cat("<script type=\"text/javascript\">\n\t<!--\n\t\taddToTOC('",header.id,"','",level,"');\n\t// -->\n</script>\n", sep="")
+		}
+	} else {
+		cat ("<h", level, ">", title, "</a></h", level, ">\n", sep="")
 	}
-	# add 'id', 'name' and 'title' attributes to the header
-	cat ("<h", level, "><a id=\"", header.id,"\" name=\"", header.id,"n\" title=\"", header.title,"\">", title, "</a></h", level, ">\n", sep="")
-	# if 'toc' is true, also add a javascript function call to add this header to the TOC menu
-	# the function addToTOC() will be defined in the document head
-	# see rk.set.output.html.file() in rk.filename-functions.R
-	if (isTRUE(toc) || (is.null(toc) && level <= 4)){
-		cat("<script type=\"text/javascript\">\n\t<!--\n\t\taddToTOC('",header.id,"','",level,"');\n\t// -->\n</script>\n", sep="")
-	}
+
 	if (length (parameters)) {
 		# legacy handling: parameter=value used to be passed as parameter, value
 		if (is.null (names (parameters))) {

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rkward-tracker mailing list