[Rcpp-commits] r3414 - pkg/Rcpp/inst/doc/Rcpp-package

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Dec 18 14:57:30 CET 2011


Author: romain
Date: 2011-12-18 14:57:30 +0100 (Sun, 18 Dec 2011)
New Revision: 3414

Modified:
   pkg/Rcpp/inst/doc/Rcpp-package/Rcpp-package.Rnw
Log:
vignette fix

Modified: pkg/Rcpp/inst/doc/Rcpp-package/Rcpp-package.Rnw
===================================================================
--- pkg/Rcpp/inst/doc/Rcpp-package/Rcpp-package.Rnw	2011-12-18 13:47:20 UTC (rev 3413)
+++ pkg/Rcpp/inst/doc/Rcpp-package/Rcpp-package.Rnw	2011-12-18 13:57:30 UTC (rev 3414)
@@ -55,34 +55,6 @@
 linkS4class <- function( cl, package, text = cl, root = "http://finzi.psych.upenn.edu/R/library/" ){
 	link( sprintf("%s-class", cl), package, text, root )
 }
-# this will be integrated to package highlight later
-ex_highlight <- function( file, external.highlight = TRUE, verbatim = FALSE ){
-	if( verbatim ){
-		writeLines( "\\begin{verbatim}" )
-		writeLines( readLines( file ) )
-		writeLines( "\\end{verbatim}" )
-	} else {
-		tf <- tempfile()
-		if( external.highlight ){
-			cmd <- sprintf( 'highlight --input="%s" --output="%s" -L --pretty-symbols', file, tf )
-			tryCatch( {
-				system( cmd )
-				tex <- readLines( tf )
-				keep <- seq( which( tex == "\\noindent" ), which( tex == "\\normalfont" ) )
-				tex <- c(
-					"\\vspace{1em}\\noindent\\fbox{\\begin{minipage}{0.9\\textwidth}" ,
-                                         gsub("^$", "%", tex[keep]),
-					"\\end{minipage}}\\vspace{1em}" )
-				writeLines( tex )
-			})
-		} else {
-			r = renderer_latex( minipage = TRUE, doc = FALSE )
-			tex <- highlight( file, renderer = r , output = NULL )
-			writeLines( tex )
-		}
-	}
-	invisible(NULL)
-}
 @
 
 \begin{document}
@@ -208,7 +180,10 @@
 package \texttt{mypackage}.
 
 <<echo=FALSE,results=tex>>=
-ex_highlight( file.path( gendir, "mypackage", "R", "rcpp_hello_world.R" ), FALSE )
+highlight( 
+    file.path( gendir, "mypackage", "R", "rcpp_hello_world.R" ), 
+    renderer = renderer_latex( doc = FALSE )
+    )
 @
 
 \pkg{Rcpp} uses the \Sexpr{link(".Call")} calling convention as it allows
@@ -227,7 +202,11 @@
 header file:
 
 <<echo=FALSE,results=tex>>=
-ex_highlight( file.path( gendir, "mypackage", "src", "rcpp_hello_world.h" )  )
+external_highlight( 
+    file.path( gendir, "mypackage", "src", "rcpp_hello_world.h" ),
+    type = "LATEX", 
+    doc = FALSE
+    )
 @
 
 The header includes the \texttt{Rcpp.h} file, which is the only file that
@@ -235,7 +214,11 @@
 the \texttt{rcpp\_hello\_world.cpp} file
 
 <<echo=FALSE,results=tex>>=
-ex_highlight( file.path( gendir, "mypackage", "src", "rcpp_hello_world.cpp" )  )
+external_highlight( 
+    file.path( gendir, "mypackage", "src", "rcpp_hello_world.cpp" ), 
+    type = "LATEX", 
+    doc = FALSE
+)
 @
 
 The function creates an \proglang{R} list that contains a
@@ -256,7 +239,7 @@
 local({
 	tf <- sprintf( "%s.make", tempfile() )
 	file.copy( file.path( gendir, "mypackage", "DESCRIPTION" ), tf )
-	ex_highlight( tf )
+	external_highlight( tf, type = "LATEX", doc = FALSE )
 	unlink( tf )
 })
 @
@@ -282,7 +265,7 @@
 local({
 	tf <- sprintf( "%s.make", tempfile() )
 	file.copy( file.path( gendir, "mypackage", "src", "Makevars" ), tf )
-	ex_highlight( tf )
+	external_highlight( tf, type = "LATEX", doc = FALSE )
 	unlink( tf )
 })
 @
@@ -293,7 +276,7 @@
 local({
 	tf <- sprintf( "%s.make", tempfile() )
 	file.copy( file.path( gendir, "mypackage", "src", "Makevars.win" ), tf )
-	ex_highlight( tf )
+	external_highlight( tf, type = "LATEX", doc = FALSE )
 	unlink( tf )
 })
 @
@@ -307,7 +290,7 @@
 local({
 	tf <- sprintf( "%s.make", tempfile() )
 	file.copy( file.path( gendir, "mypackage", "NAMESPACE" ), tf )
-	ex_highlight( tf )
+	external_highlight( tf, type = "LATEX", doc = FALSE )
 	unlink( tf )
 })
 @
@@ -337,7 +320,7 @@
 local({
 	tf <- sprintf( "%s.make", tempfile() )
 	file.copy( file.path( gendir, "mypackage", "man", "mypackage-package.Rd" ), tf )
-	ex_highlight( tf )
+	external_highlight( tf, type = "LATEX", doc = FALSE )
 	unlink( tf )
 })
 @
@@ -352,7 +335,7 @@
 local({
 	tf <- sprintf( "%s.make", tempfile() )
 	file.copy( file.path( gendir, "mypackage", "man", "rcpp_hello_world.Rd" ), tf )
-	ex_highlight( tf )
+	external_highlight( tf, type = "LATEX", doc = FALSE )
 	unlink( tf )
 })
 @



More information about the Rcpp-commits mailing list