[rkward-cvs] SF.net SVN: rkward-code:[4897] trunk/rkward/packages/rkwarddev

m-eik at users.sf.net m-eik at users.sf.net
Sun Oct 12 19:37:20 UTC 2014


Revision: 4897
          http://sourceforge.net/p/rkward/code/4897
Author:   m-eik
Date:     2014-10-12 19:37:17 +0000 (Sun, 12 Oct 2014)
Log Message:
-----------
rkwarddev: enhanced the R code shown by the skeleton dialog to be a better start for your own rkwarddev scripts (optionset still refuses to work, btw...)

Modified Paths:
--------------
    trunk/rkward/packages/rkwarddev/R/tf.R
    trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
    trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.js
    trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.rkh
    trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.xml

Modified: trunk/rkward/packages/rkwarddev/R/tf.R
===================================================================
--- trunk/rkward/packages/rkwarddev/R/tf.R	2014-10-12 18:07:13 UTC (rev 4896)
+++ trunk/rkward/packages/rkwarddev/R/tf.R	2014-10-12 19:37:17 UTC (rev 4897)
@@ -23,7 +23,7 @@
 #' by default \code{TRUE} or \code{FALSE} (hence the name, abbreviated "true or false").
 #' The same result can be obtained with \code{ite}, but for most common cases \code{tf} is much quicker.
 #' 
-#' @param cbox An obkect of class \code{XiMpLe.node} containing a \code{<checkbox>} node, as generated
+#' @param cbox An object of class \code{XiMpLe.node} containing a \code{<checkbox>} node, as generated
 #'    by \code{\link[rkwarddev:rk.XML.cbox]{rk.XML.cbox}}.
 #' @param true Logical or character, the value the option should get. E.g., if \code{true=TRUE} then the option will be
 #'    set to \code{TRUE} if the box is checked, or in case \code{not=TRUE}, if the box is not checked.

Modified: trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R
===================================================================
--- trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2014-10-12 18:07:13 UTC (rev 4896)
+++ trunk/rkward/packages/rkwarddev/demo/skeleton_dialog.R	2014-10-12 19:37:17 UTC (rev 4897)
@@ -138,30 +138,45 @@
 
 tab2.create <- rk.XML.col(crt.opts, dep.opts)
 
-# tab3: varslot to select the actual content
-children.text <- rk.XML.text("If you already created XML content for the plugin, select the main dialog object here (probably a tabbook?)")
-children.var <- rk.XML.row(
-  children.varselector <- rk.XML.varselector(label="Plugin content"),
-  rk.XML.col(
-    cont.dial <- rk.XML.varslot("Select an object of class XiMpLe.node", source=children.varselector, classes="XiMpLe.node",
-      help="If you already created XML content for the plugin, select the main dialog object here."),
-    rk.XML.frame(
-      js.prep <- rk.XML.varslot("preprocess()", source=children.varselector,
-        help="A JavaScript object to be used as the the preprocess() function."),
-      js.calc <- rk.XML.varslot("calculate()", source=children.varselector,
-        help="A JavaScript object to be used as the the calculate() function."),
-      js.prnt <- rk.XML.varslot("printout()", source=children.varselector,
-        help="A JavaScript object to be used as the the printout() function."),
-      rk.XML.stretch())
-  ))
-tab3.children <- rk.XML.col(rk.XML.row(children.text), rk.XML.row(children.var))
+# # tab3: varslot to select the actual content
+# children.text <- rk.XML.text("If you already created XML content for the plugin, select the main dialog object here (probably a tabbook?)")
+# children.var <- rk.XML.row(
+#   children.varselector <- rk.XML.varselector(label="Plugin content"),
+#   rk.XML.col(
+#     cont.dial <- rk.XML.varslot("Select an object of class XiMpLe.node", source=children.varselector, classes="XiMpLe.node",
+#       help="If you already created XML content for the plugin, select the main dialog object here."),
+#     rk.XML.frame(
+#       js.prep <- rk.XML.varslot("preprocess()", source=children.varselector,
+#         help="A JavaScript object to be used as the the preprocess() function."),
+#       js.calc <- rk.XML.varslot("calculate()", source=children.varselector,
+#         help="A JavaScript object to be used as the the calculate() function."),
+#       js.prnt <- rk.XML.varslot("printout()", source=children.varselector,
+#         help="A JavaScript object to be used as the the printout() function."),
+#       rk.XML.stretch())
+#   ))
+# tab3.children <- rk.XML.col(rk.XML.row(children.text), rk.XML.row(children.var))
+help.text.summary <- rk.XML.input("Summary", size="large",
+  help="Give a short summary of the plugin for the help page. If empty, the short description is taken as the default.")
+help.text.usage <- rk.XML.input("Usage", size="large",
+  help="A general note on how to use the plugin.")
+help.text <- rk.XML.frame(
+  rk.XML.row(help.text.summary),
+  rk.XML.row(help.text.usage),
+  label="Write help files",
+  checkable=TRUE,
+  chk=FALSE)
+  
+tab3.help <- rk.XML.col(help.text)
 
 ## glue all of the above together in one tabbook
 # sklt.tabbook <- rk.XML.dialog(rk.XML.tabbook("Plugin Skeleton",
 #   tab.labels=c("About the plugin", "Create options", "XML content"),
 #   children=list(tab1.about, tab2.create, tab3.children)), label="RKWard Plugin Skeleton")
 sklt.tabbook <- rk.XML.dialog(rk.XML.tabbook("Plugin Skeleton",
-  tabs=list("About the plugin"=tab1.about, "Create options"=tab2.create)),
+  tabs=list(
+    "About the plugin"=tab1.about,
+    "Create options"=tab2.create,
+    "Help page"=tab3.help)),
   label="RKWard Plugin Skeleton")
 
 ## some logic
@@ -205,16 +220,25 @@
   ite(id(pl.hier, "!= \"test\""), qp("hierarchy=\"", pl.hier, "\"")),
   funct="list", option="pluginmap", collapse="")
 js.opt.skeleton <- rk.JS.options("optSkeleton",
-  ite(pl.dir, qp("\n\tpath=\"", pl.dir, "\"")),
   ite(pl.wiz, qp("\n\tprovides=c(\"logic\", \"dialog\", \"wizard\")")),
   ite(js.opt.skel.pluginmap, qp("\n\t", js.opt.skel.pluginmap)),
-  ite(pl.overw, qp("\n\toverwrite=TRUE")),
   ite(pl.tests, qp("\n\ttests=TRUE")),
   ite(pl.edit, qp("\n\tedit=TRUE")),
   ite(pl.add, qp("\n\tload=TRUE")),
   ite(pl.show, qp("\n\tshow=TRUE")),
   collapse="")
 
+JS.prepare <- rk.paste.JS(
+  rk.JS.vars(pl.dir, pl.overw),
+  echo("rkwarddev.required(\"0.06-5\")"),
+  echo("\n\n# define where the plugin should write its files\noutput.dir <- "),
+  ite(pl.dir, echo("\"", pl.dir, "\""), echo("tempdir()")),
+  echo("\n# overwrite an existing plugin in output.dir?\noverwrite <- "),
+  ite(pl.overw, echo("TRUE"), echo("FALSE")),
+  echo("\n\n"),
+  level=2)
+  
+js.frm.help.text <- rk.JS.vars(help.text, modifiers="checked")
 JS.calculate <- rk.paste.JS(
   js.opt.about.author.role,
   js.opt.about.author,
@@ -236,9 +260,29 @@
         echo("\n\tpackage=list(\n\t\tc(name=\"", join(dep.optioncol.pckg.name, by="\"),\n\t\tc(name=\""), "\")\n\t)")),
       echo("\n)\n\n"),
     level=3)),
-  echo("plugin.dir <- rk.plugin.skeleton(\n\tabout=about.plugin,"),
-    ite(id(js.frm.dep.opts, " && ", js.opt.about.dep), echo("\n\tdependencies=plugin.dependencies,")),
-    echo(js.opt.skeleton),
+  ite(js.frm.help.text,
+    rk.paste.JS(
+      echo("############\n## help page\nplugin.summary <- rk.rkh.summary(\n\t"),
+      ite(help.text.summary, echo("\"", help.text.summary, "\"\n)"), echo("\"", pl.desc, "\"\n)")),
+      echo("\nplugin.usage <- rk.rkh.usage(\n\t\"", help.text.usage, "\"\n)\n\n"),
+    level=3)),
+  echo("#############\n",
+    "## the main call\n",
+    "## if you run the following function call, files will be written to output.dir!\n",
+    "#############\n",
+    "# this is where things get serious, that is, here all of the above is put together into one plugin\n",
+    "plugin.dir <- rk.plugin.skeleton(\n\tabout=about.plugin,"),
+  ite(id(js.frm.dep.opts, " && ", js.opt.about.dep), echo("\n\tdependencies=plugin.dependencies,")),
+  echo("\n\tpath=output.dir,"),
+  echo("\n\toverwrite=overwrite,"),
+  ite(js.frm.help.text,
+    echo(
+      "\n\trkh=list(\n\t\tsummary=plugin.summary,\n\t\tusage=plugin.usage\n\t),",
+      "\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\", \"rkh\"),"
+    ),
+    echo("\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\"),")
+  ),
+  echo(js.opt.skeleton),
   echo("\n)\n\n"),
   level=2)
 
@@ -265,6 +309,7 @@
     logic=logic.section),
   js=list(
     require="rkwarddev",
+    preprocess=JS.prepare,
     calculate=JS.calculate),
   rkh=list(
     summary=rkh.summary,
@@ -277,6 +322,6 @@
   tests=FALSE,
   show=TRUE,
 #  load=TRUE,
-  edit=TRUE,
+#  edit=TRUE,
   hints=FALSE)
 })

Modified: trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.js
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.js	2014-10-12 18:07:13 UTC (rev 4896)
+++ trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.js	2014-10-12 19:37:17 UTC (rev 4897)
@@ -6,6 +6,23 @@
 function preprocess(){
 	// add requirements etc. here
 	echo("require(rkwarddev)\n");
+
+	var brwDTEMPDIR = getValue("brw_DTEMPDIR");
+	var chcOvrwrtxs = getValue("chc_Ovrwrtxs");
+	echo("rkwarddev.required(\"0.06-5\")");
+	echo("\n\n# define where the plugin should write its files\noutput.dir <- ");
+	if(brwDTEMPDIR) {
+		echo("\"" + brwDTEMPDIR + "\"");
+	} else {
+		echo("tempdir()");
+	}
+	echo("\n# overwrite an existing plugin in output.dir?\noverwrite <- ");
+	if(chcOvrwrtxs) {
+		echo("TRUE");
+	} else {
+		echo("FALSE");
+	}
+	echo("\n\n");
 }
 
 function calculate(){
@@ -35,7 +52,10 @@
 	var inpRKWardmx = getString("inp_RKWardmx");
 	var inpRmin = getString("inp_Rmin");
 	var inpRmax = getString("inp_Rmax");
+	var inpSummary = getString("inp_Summary");
+	var inpUsage = getString("inp_Usage");
 	var frmDfndpndnChecked = getBoolean("frm_Dfndpndn.checked");
+	var frmWrthlpflChecked = getBoolean("frm_Wrthlpfl.checked");
 
 	// the R code to be evaluated
 	// define the array arrOptAuthorRole for values of R option "role"
@@ -146,18 +166,12 @@
 
 	// define the array arrOptSkeleton for values of R option ""
 	var arrOptSkeleton = new Array();
-		if(brwDTEMPDIR) {
-			arrOptSkeleton.push("\n\tpath=\"" + brwDTEMPDIR + "\"");
-		}
 		if(chcAddwzrds) {
 			arrOptSkeleton.push("\n\tprovides=c(\"logic\", \"dialog\", \"wizard\")");
 		}
 		if(optPluginmap) {
 			arrOptSkeleton.push("\n\t" + optPluginmap);
 		}
-		if(chcOvrwrtxs) {
-			arrOptSkeleton.push("\n\toverwrite=TRUE");
-		}
 		if(chcIncldplg) {
 			arrOptSkeleton.push("\n\ttests=TRUE");
 		}
@@ -199,10 +213,26 @@
 		}
 		echo("\n)\n\n");
 	}
-	echo("plugin.dir <- rk.plugin.skeleton(\n\tabout=about.plugin,");
+	if(frmWrthlpflChecked) {
+		echo("############\n## help page\nplugin.summary <- rk.rkh.summary(\n\t");
+		if(inpSummary) {
+			echo("\"" + inpSummary + "\"\n)");
+		} else {
+			echo("\"" + inpShrtdscr + "\"\n)");
+		}
+		echo("\nplugin.usage <- rk.rkh.usage(\n\t\"" + inpUsage + "\"\n)\n\n");
+	}
+	echo("#############\n" + "## the main call\n" + "## if you run the following function call, files will be written to output.dir!\n" + "#############\n" + "# this is where things get serious, that is, here all of the above is put together into one plugin\n" + "plugin.dir <- rk.plugin.skeleton(\n\tabout=about.plugin,");
 	if(frmDfndpndnChecked && optDependencies) {
 		echo("\n\tdependencies=plugin.dependencies,");
 	}
+	echo("\n\tpath=output.dir,");
+	echo("\n\toverwrite=overwrite,");
+	if(frmWrthlpflChecked) {
+		echo("\n\trkh=list(\n\t\tsummary=plugin.summary,\n\t\tusage=plugin.usage\n\t)," + "\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\", \"rkh\"),");
+	} else {
+		echo("\n\tcreate=c(\"pmap\", \"xml\", \"js\", \"desc\"),");
+	}
 	echo(optSkeleton);
 	echo("\n)\n\n");
 }

Modified: trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.rkh
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.rkh	2014-10-12 18:07:13 UTC (rev 4896)
+++ trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.rkh	2014-10-12 19:37:17 UTC (rev 4897)
@@ -103,6 +103,14 @@
 			The names of R packages required to run this plugin.
 		</setting>
 		<setting id="ocl_inpPckgtxt" />
+		<caption id="tab_Helppage" />
+		<caption id="frm_Wrthlpfl" />
+		<setting id="inp_Summary">
+			Give a short summary of the plugin for the help page. If empty, the short description is taken as the default.
+		</setting>
+		<setting id="inp_Usage">
+			A general note on how to use the plugin.
+		</setting>
 	</settings>
 	<!-- <related>
 				<ul>

Modified: trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.xml
===================================================================
--- trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.xml	2014-10-12 18:07:13 UTC (rev 4896)
+++ trunk/rkward/packages/rkwarddev/inst/rkward/plugins/CreateRKWardpluginskeleton.xml	2014-10-12 19:37:17 UTC (rev 4897)
@@ -114,6 +114,18 @@
 					</frame>
 				</column>
 			</tab>
+			<tab label="Help page" id="tab_Helppage">
+				<column id="clm_fWWSSSSUUU">
+					<frame label="Write help files" checkable="true" checked="false" id="frm_Wrthlpfl">
+						<row id="row_inptlblSmS">
+							<input label="Summary" id="inp_Summary" size="large" />
+						</row>
+						<row id="row_inptlblUsU">
+							<input label="Usage" id="inp_Usage" size="large" />
+						</row>
+					</frame>
+				</column>
+			</tab>
 		</tabbook>
 	</dialog>
 </document>





More information about the rkward-tracker mailing list