[Rcpp-commits] r1511 - pkg/Rcpp/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 11 08:10:35 CEST 2010


Author: romain
Date: 2010-06-11 08:10:34 +0200 (Fri, 11 Jun 2010)
New Revision: 1511

Added:
   pkg/Rcpp/R/help.R
Modified:
   pkg/Rcpp/R/zzz.R
Log:
work around to support accessing documentation through Rcpp ? something

Added: pkg/Rcpp/R/help.R
===================================================================
--- pkg/Rcpp/R/help.R	                        (rev 0)
+++ pkg/Rcpp/R/help.R	2010-06-11 06:10:34 UTC (rev 1511)
@@ -0,0 +1,43 @@
+# Copyright (C) 2010	Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
+
+.help <- function( what ){
+	print( sprintf( "Rcpp help for '%s'", what ) )
+	invisible(TRUE)
+}
+
+install_help_workaround <- function(){
+	utils <- asNamespace( "utils" )
+	unlockBinding( ".tryHelp", utils )
+	th <- get( ".tryHelp", utils )
+	b <- body( th )
+	b <- as.call( c( 
+			as.name( "{" ), 
+			quote( 
+				if( grepl( "[-]Rcpp$", topic ) ){
+					result <- Rcpp:::.help( sub( "[-]Rcpp$", "", topic ) )
+					if( result )
+						return( invisible(NULL) )
+				}
+			), 
+			as.list( b[-1] )
+		) )
+	body( th ) <- b
+	assign( ".tryHelp", th, utils )
+	lockBinding( ".tryHelp", utils )
+}
+

Modified: pkg/Rcpp/R/zzz.R
===================================================================
--- pkg/Rcpp/R/zzz.R	2010-06-10 22:15:39 UTC (rev 1510)
+++ pkg/Rcpp/R/zzz.R	2010-06-11 06:10:34 UTC (rev 1511)
@@ -15,5 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
-.onLoad <- function(libname, pkgname){}
+.onLoad <- function(libname, pkgname){
+	install_help_workaround()
+}
 



More information about the Rcpp-commits mailing list