[Sciviews-commits] r213 - in pkg/svTools: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Oct 17 15:10:26 CEST 2009


Author: romain
Date: 2009-10-17 15:10:25 +0200 (Sat, 17 Oct 2009)
New Revision: 213

Modified:
   pkg/svTools/DESCRIPTION
   pkg/svTools/NAMESPACE
   pkg/svTools/NEWS
   pkg/svTools/R/sidekick.R
   pkg/svTools/man/sidekick.Rd
Log:
sidekick becomes generic

Modified: pkg/svTools/DESCRIPTION
===================================================================
--- pkg/svTools/DESCRIPTION	2009-10-15 17:34:23 UTC (rev 212)
+++ pkg/svTools/DESCRIPTION	2009-10-17 13:10:25 UTC (rev 213)
@@ -6,11 +6,11 @@
 Description: Set of tools aimed at wrapping some of the functionalities
   of the packages tools, utils and codetools into a nicer format so
   that an IDE can use them
-Version: 0.0-11
-Date: 2009-08-10
+Version: 0.0-12
+Date: 2009-10-17
 Author: Romain Francois
 Maintainer: Romain Francois <francoisromain at free.fr>
 License: GPL (>= 2)
 LazyLoad: yes
 LazyData: yes
-URL: http://www.sciviews.org/SciViews-R
+URL: http://www.sciviews.org/SciViews-R, http://romainfrancois.blog.free.fr/

Modified: pkg/svTools/NAMESPACE
===================================================================
--- pkg/svTools/NAMESPACE	2009-10-15 17:34:23 UTC (rev 212)
+++ pkg/svTools/NAMESPACE	2009-10-17 13:10:25 UTC (rev 213)
@@ -1,10 +1,13 @@
-import(utils, tools, codetools, svMisc, operators)
+import(utils, tools, codetools, svMisc, operators )
 
 export(generateRoxygenTemplate)
 export(checkUsageFile)
 
 # sidekick.R
 export(sidekick)
+S3method( sidekick, "function") 
+S3method( sidekick, "default")
+S3method( sidekick, "character")
 
 # errorlist.R
 #export(getErrors)

Modified: pkg/svTools/NEWS
===================================================================
--- pkg/svTools/NEWS	2009-10-15 17:34:23 UTC (rev 212)
+++ pkg/svTools/NEWS	2009-10-17 13:10:25 UTC (rev 213)
@@ -1,10 +1,13 @@
 = svTools News
 
+== Changes in svTools 0.0-12
+
+* sidekick is now generic 
+
 == Changes in svTools 0.0-11
 
 * Further clean up of the NAMESPACE and DESCRIPTION files
 
-
 == Changes in svTools 0.0-10
 
 * Cleaning for CRAN submission

Modified: pkg/svTools/R/sidekick.R
===================================================================
--- pkg/svTools/R/sidekick.R	2009-10-15 17:34:23 UTC (rev 212)
+++ pkg/svTools/R/sidekick.R	2009-10-17 13:10:25 UTC (rev 213)
@@ -17,22 +17,30 @@
 #' sidekick( tf )
 #' unlink( tf )
 #' TODO :make this S3 instead of dispatching
-sidekick <- function( file, encoding = getOption("encoding") ){
-	
-	if( file %of% "function" ){
-		tf <- tempfile( ); on.exit( unlink( tf ) )
-		dump( "file" , tf )
-		file <- tf
+
+sidekick <- function( x, ... ){
+	UseMethod( "sidekick" )
+}
+
+sidekick.default <- function(x, ... ){
+	.NotYetImplemented()
+}
+
+sidekick.function <- function(x, ...){
+	tf <- tempfile( ); on.exit( unlink( tf ) )
+	dump( "x" , file = tf )
+	sidekick.character( tf, encoding = "unknown", delete.file = TRUE )
+}
+
+sidekick.character <- function(x, encoding = getOption("encoding"), delete.file = FALSE, ... ){
+	if( delete.file ){
+		on.exit( { unlink( x ) } )
 	}
 	
-	if( is.character(file) ){
-		if( file %~% '^rwd:' ){
-			file <- sub( 'rwd:', getwd(), file ) 
-		}
-	}
-	
 	### try to parse and return an error if failed
-	p <- try( parse( file, encoding = encoding ), silent = TRUE )
+	f <- file( x, open ="r", encoding = encoding )
+	p <- try( parse( f, srcfile = srcfile(x, encoding) ), silent = TRUE )
+	close(f)
 	if( p %of% "try-error" ){
 		return( list( type = "error", data = parseError( p ) ) )
 	}
@@ -69,7 +77,6 @@
 	} else {
 		maxId <- max( env[["data"]][, "id"] ) 
 	}
-	
 	isIf <- looksLikeAnIf( p )
 	atts <- attributes( p )
 	descriptions <- as.character( p )
@@ -123,7 +130,7 @@
 				}
 			}
 		}
-	}
+	}        
 	if( top ){
 		env[["data"]]
 	}

Modified: pkg/svTools/man/sidekick.Rd
===================================================================
--- pkg/svTools/man/sidekick.Rd	2009-10-15 17:34:23 UTC (rev 212)
+++ pkg/svTools/man/sidekick.Rd	2009-10-17 13:10:25 UTC (rev 213)
@@ -1,6 +1,9 @@
 \name{sidekick}
 \Rdversion{1.1}
 \alias{sidekick}
+\alias{sidekick.character}
+\alias{sidekick.default}
+\alias{sidekick.function}
 \title{
 	Builds a tree structure of an R source file
 }
@@ -9,17 +12,17 @@
 	an R code file by analysing output of the R parser
 }
 \usage{
-sidekick(file, encoding = getOption("encoding"))
+sidekick( x, ... )
+\S3method{sidekick}{character}(x, encoding = getOption("encoding"), delete.file = FALSE, ... )
+\S3method{sidekick}{default}(x, ... )
+\S3method{sidekick}{function}(x, ... ) 
 }
 \arguments{
-  \item{file}{
-	  A file to \code{\link{parse}} and analyse. If \code{file}
-	  is a function, it is first dumped into a file.
+  \item{x}{A file to \code{\link{parse}} and analyse. If \code{x} is a function, it is first dumped into a file.}
+  \item{encoding}{Encoding to use. Default to the encoding option (see \link{options})}
+  \item{delete.file}{delete file }
+  \item{...}{...}
 }
-  \item{encoding}{
-	  Encoding to use. Default to the encoding option (see \link{options})
-}
-}
 \value{
 A Data frame with columns:
 \item{id}{}
@@ -36,10 +39,10 @@
 }
 
 \seealso{
-	\code{\link{parse}}
+	\code{\link[parser]{parser}}
 }
 \examples{
-	sidekick( outer )
+	\dontrun{sidekick( outer )}
 }
 \keyword{ manip }
 



More information about the Sciviews-commits mailing list