[rkward-cvs] SF.net SVN: rkward:[2701] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Thu Oct 8 09:16:32 UTC 2009


Revision: 2701
          http://rkward.svn.sourceforge.net/rkward/?rev=2701&view=rev
Author:   tfry
Date:     2009-10-08 09:16:31 +0000 (Thu, 08 Oct 2009)

Log Message:
-----------
Do not rely on help() returning a (valid) path

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
    trunk/rkward/rkward/rbackend/rpackages/rkward/R/ver.R
    trunk/rkward/rkward/resource.ver
    trunk/rkward/rkward/version.h
    trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-10-08 09:09:50 UTC (rev 2700)
+++ trunk/rkward/ChangeLog	2009-10-08 09:16:31 UTC (rev 2701)
@@ -1,6 +1,6 @@
 	  TODO: Test new output detection on windows
 - All directly accessible plugins now have at least one automated test
-- Add support for the dynamic help server introduced in R 2.10.0	TODO: backport (r2672, r2677)
+- Add support for the dynamic help server introduced in R 2.10.0	TODO: backport (r2672, r2677, r2701)
 - Assorted minor fixes and improvements to several plugins
 - Fix deadlock while handling some Tcl events		TODO: backport? (r2649)
 - Plugin dialogs close automatically after submitting (by default)

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2009-10-08 09:09:50 UTC (rev 2700)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal.R	2009-10-08 09:16:31 UTC (rev 2701)
@@ -429,3 +429,19 @@
 	}
 	return (paste ("http://127.0.0.1", port, sep=":"))
 }
+
+# a simple wrapper around help() that makes it easier to detect in code, whether help was found or not.
+# used from RKHelpSearchWindow::getFunctionHelp
+".rk.getHelp" <- function (...) {
+	if (compareVersion (as.character (getRversion()), "2.10.0") >= 0) {
+		res <- help (..., help_type="html")
+	} else {
+		res <- help (..., chmhelp=FALSE, htmlhelp=TRUE)
+	}
+	if (!length (as.character (res))) {	# this seems undocumented, but it is what utils:::print.help_files_with_topic checks
+		show (res)
+		stop ("No help found")
+	}
+	show (res)
+	invisible (TRUE)
+}

Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/ver.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/ver.R	2009-10-08 09:09:50 UTC (rev 2700)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/ver.R	2009-10-08 09:16:31 UTC (rev 2701)
@@ -1 +1 @@
-".rk.app.version" <- "0.5.2-pre1"
+".rk.app.version" <- "0.5.2-pre2"

Modified: trunk/rkward/rkward/resource.ver
===================================================================
--- trunk/rkward/rkward/resource.ver	2009-10-08 09:09:50 UTC (rev 2700)
+++ trunk/rkward/rkward/resource.ver	2009-10-08 09:16:31 UTC (rev 2701)
@@ -1 +1 @@
-0.5.2-pre1
+0.5.2-pre2

Modified: trunk/rkward/rkward/version.h
===================================================================
--- trunk/rkward/rkward/version.h	2009-10-08 09:09:50 UTC (rev 2700)
+++ trunk/rkward/rkward/version.h	2009-10-08 09:16:31 UTC (rev 2701)
@@ -1,2 +1,2 @@
 /* Version number of package */
-#define VERSION "0.5.2-pre1"
+#define VERSION "0.5.2-pre2"

Modified: trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2009-10-08 09:09:50 UTC (rev 2700)
+++ trunk/rkward/rkward/windows/rkhelpsearchwindow.cpp	2009-10-08 09:16:31 UTC (rev 2701)
@@ -40,7 +40,7 @@
 #include "../misc/rkcommonfunctions.h"
 #include "../misc/rkdummypart.h"
 
-#define GET_HELP_URL 1
+#define GET_HELP 1
 #define HELP_SEARCH 2
 #define GET_INSTALLED_PACKAGES 3
 
@@ -152,15 +152,12 @@
 void RKHelpSearchWindow::getFunctionHelp (const QString &function_name, const QString &package) {
 	RK_TRACE (APP);
 
-	QString command = "help(\"" + function_name + '\"';
+	// we use .rk.getHelp() instead of plain help() to receive an error, if no help could be found
+	QString command = ".rk.getHelp(\"" + function_name + '\"';
 	if (!package.isEmpty ()) command.append (", package=" + package);
-	command.append (", chmhelp=FALSE, htmlhelp=TRUE)[1]");
+	command.append (")");
 
-	RKGlobals::rInterface ()->issueCommand (command, RCommand::App | RCommand::GetStringVector, i18n ("Find HTML help for %1").arg (function_name), this, GET_HELP_URL);
-
-	// we *could* simply call show() on the object that help() returns. However, since this function
-	// may be called externally, we need to handle the case when no help can be found. So we use
-	// this two-stage approach, instead.
+	RKGlobals::rInterface ()->issueCommand (command, RCommand::App | RCommand::GetStringVector, i18n ("Find HTML help for %1").arg (function_name), this, GET_HELP);
 }
 
 void RKHelpSearchWindow::slotFindButtonClicked () {
@@ -218,17 +215,8 @@
 
 		for (int i = 0; i < COL_COUNT; ++i) results_view->resizeColumnToContents (i);
 		setEnabled(true);
-	} else if (command->getFlags () == GET_HELP_URL) {
-		QString help_file;
-
-		if (command->getDataLength ()) {
-			RK_ASSERT (command->getDataType () == RData::StringVector);
-			help_file = command->getStringVector ()[0];
-		}
-		if (QFile::exists (help_file)) {
-			RKWardMainWindow::getMain ()->openHTML (KUrl::fromPath (help_file));
-			return;
-		} else {
+	} else if (command->getFlags () == GET_HELP) {
+		if (command->failed ()) {
 			KMessageBox::sorry (this, i18n ("No help found on '%1'. Maybe the corresponding package is not installed/loaded, or maybe you mistyped the command. Try using Help->Search R Help for more options.", command->command ().section ("\"", 1, 1)), i18n ("No help found"));
 		}
 	} else if (command->getFlags () == GET_INSTALLED_PACKAGES) {


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