[Sciviews-commits] r512 - in pkg/svDoc: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 11 18:28:28 CET 2013


Author: phgrosjean
Date: 2013-01-11 18:28:27 +0100 (Fri, 11 Jan 2013)
New Revision: 512

Modified:
   pkg/svDoc/NAMESPACE
   pkg/svDoc/R/asciidoc.R
   pkg/svDoc/R/header.R
   pkg/svDoc/TODO
   pkg/svDoc/man/asciidoc.Rd
   pkg/svDoc/man/header.Rd
Log:
Further corrections for dynamic svDocs in svDoc

Modified: pkg/svDoc/NAMESPACE
===================================================================
--- pkg/svDoc/NAMESPACE	2013-01-11 15:31:12 UTC (rev 511)
+++ pkg/svDoc/NAMESPACE	2013-01-11 17:28:27 UTC (rev 512)
@@ -3,6 +3,8 @@
 
 export(header,
        render...,
+       svDocRender,
        svDocToRnw,
-       svDocConvert,
        svDocThemes)
+
+S3method(print, renderer)

Modified: pkg/svDoc/R/asciidoc.R
===================================================================
--- pkg/svDoc/R/asciidoc.R	2013-01-11 15:31:12 UTC (rev 511)
+++ pkg/svDoc/R/asciidoc.R	2013-01-11 17:28:27 UTC (rev 512)
@@ -97,7 +97,7 @@
 }
 
 ## TODO: use figs.dir!!!
-svDocConvert <- function (svDocFile, theme, format, show.it, figs.dir,
+svDocRender <- function (svDocFile, theme, format, show.it, figs.dir,
 keep.RnwFile, keep.TxtFile, encoding, asciidoc)
 {
 	## If svDocFile is missing, try to get it from option or the command line
@@ -128,6 +128,7 @@
 	}
 	
 	## If format is missing, try getting it from options(), or assume "html"
+	## TODO: get it from the document itself!!!
 	if (missing(format)) format <- getOption("svDoc.format", "html")
 	## The resulting file extension depends on the format used
 	## Note that EndFile is always at same location as TxtFile
@@ -280,7 +281,7 @@
 	## Check svDocFile
 	if (missing(svDocFile) || !length(svDocFile)) stop("No file provided")
 	if (!file.exists(svDocFile)) stop("svDocFile not found (", svDocFile, ")")
-	svocFile <- normalizePath(svDocFile)
+	svDocFile <- normalizePath(svDocFile)
 	
 	## Get encoding
 	if (missing(encoding)) encoding <- getOption("svDoc.encoding", "UTF-8")	
@@ -305,7 +306,18 @@
 	oencoding <- options(svDoc.encoding = encoding)$svDoc.encoding
 	on.exit(options(svDoc.file = ofile, encoding = oencoding))
 	
-	## Run that command
-	cmd <- try(parse(text = cmdNoQuotes))
-	if (!inherits(cmd, "try-error")) eval(cmd, envir = parent.frame())
+	## If the command is me (svDoc::render...), then call svDocRender()
+	if (cmdNoQuotes == "svDoc::render...") {
+		svDocRender()
+	} else {
+		## Run that command, first replacing svDoc::render... by svDocRender
+		cmdNoQuotes <- gsub("svDoc::render\\.\\.\\.", "svDoc::svDocRender",
+			cmdNoQuotes)
+		cmd <- try(parse(text = cmdNoQuotes))
+		if (!inherits(cmd, "try-error")) eval(cmd, envir = parent.frame())
+	}
 }
+
+class(render...) <- c("renderer", "function")
+
+print.renderer <- function (x, ...) unclass(x)()

Modified: pkg/svDoc/R/header.R
===================================================================
--- pkg/svDoc/R/header.R	2013-01-11 15:31:12 UTC (rev 511)
+++ pkg/svDoc/R/header.R	2013-01-11 17:28:27 UTC (rev 512)
@@ -3,7 +3,7 @@
 header <- function (title, author = NULL, email = NULL, revnumber = NULL,
 revdate = NULL, revremark = NULL, copyright = "cc-by", encoding = "UTF-8",
 lang = "en", pagetitle = NULL, description = "SciViews document", keywords = NULL,
-theme = "sciviews", max.width = 640, width = NULL,
+format = NULL, theme = "sciviews", max.width = 640, width = NULL,
 toc = c("top", "side", "manual", "none"), toc.title = NULL, toclevels = 2,
 numbered = TRUE, data.uri = TRUE, frame = "topbot", grid = "rows",
 align = "center", halign = "center", pygments = FALSE, slidefontsizeadjust = 0,
@@ -22,7 +22,7 @@
 	
 	## Title must be a single string and start with '= '
 	if (length(title)) header <- paste0(as.character(title)[1], "\n")
-	if (substring("= ", 1, 2) != "= ") header <- paste("=", header)
+	if (substring(header, 1, 2) != "= ") header <- paste("=", header)
 	
 	## Idem for author, but allow several names
 	if (length(author)) {
@@ -72,6 +72,7 @@
 	header <- asciiAttr(header, "title", pagetitle)
 	header <- asciiAttr(header, "description", description)
 	header <- asciiAttr(header, "keywords", keywords)
+	header <- asciiAttr(header, "format", format)
 	header <- asciiAttr(header, "theme", theme)
 	header <- asciiAttr(header, "max-width", max.width)
 	header <- asciiAttr(header, "width", width)

Modified: pkg/svDoc/TODO
===================================================================
--- pkg/svDoc/TODO	2013-01-11 15:31:12 UTC (rev 511)
+++ pkg/svDoc/TODO	2013-01-11 17:28:27 UTC (rev 512)
@@ -1,20 +1,61 @@
 = svDoc - To do list
 
-* Package svShiny code here + runExample()/runGist()
+* Use format provided by the svDoc header, if not provided
 
-* Use more sensible values for toc: if missing and no author/revfield => no toc.
+* Allow compiling docs without #! and/or svDoc::header()!
 
-* A better management of theme: define one form html and one for slidy/slidy2.
+* Detect dynamic vs static svDoc and react accordingly (also allow to compile
+  static docs from withing the doc server)
+  
+* In Komodo: auto open/close doc server on building dynamic page or exiting
 
+* doc server => recover from error + indicate it in the page
+
+* Other tags that //italic// because of clash with http://site.org
+
+* Add googleVis
+
+* Asciidoc tags for shiny UI
+
+* Pipe to Asciidoc + keep in memory to speed up things, also for Rnw and html
+
+* Test render... with #! on Linux and Mac
+
+* Test all on Windows on Linux
+
+* Include additions (+ share code + github) in SciViews-K
+
+* koDoc vs document in SciViews-K + linter/completion/calltips
+
+* Fonts inside svDocs + correct fonts in sciviews style
+
+* Page with features + message on install of new SciViews-K
+
+* Update packages in SciViews-K, including svDoc, RCurl, formatR, ascii, etc...
+
+* Use sciviews.r.page.port in start + svKomodo
+
+* Get distant file from pzt => propose to save locally first.
+
+* Pastecs namespace + onload 2 packages + deprecated svMisc + new packages => CRAN
+
+* New version of SciViews-k to Activestate site
+
+* Update the SciViews-R and -K sites.
+
+* Package svShiny code here + runExample()/runGist()
+
 * With the shiny jslider, I would like to be able to move left cursor and keep
   interval between left and right cursor constant... or, better, be able to drag
   the interval between the two cursors.
   
+* Download/upload widget in Komodo Edit
+  
 * Make a better default_shiny.R page that lists all existing pages on the server
 
 * Rename xxx_shiny.R as xxx.svDoc, simply?!
 
-* Make interface for writing SciViews documents in Komodo/SciViews-K.
+* Make toolbar for writing SciViews documents in Komodo/SciViews-K.
 
 * ascii() => view() + aware if ascii or latex and results=ascii/tex accordingly
 
@@ -23,7 +64,7 @@
 * Also allow to convert from LyX/LaTeX to Asciidoc
 
 * Enable timer events on the page server and daemonize it on Windows
-  (using Tcl loop)?
+  (using Tcl loop)? Also integrate svShiny server text
   
 * A better logic for startPageServer() call, e.g., if the server does not run
   and a page is created
@@ -38,7 +79,7 @@
 * Numbered items for figures, tables, equations and listings using Asciidoc
   replacement macros
   
-* Save/reload pages installed on a server with R code
+* Save/reload pages installed on a server with R code (pzt, pastebin + add gist)
 
 * Eliminate footer for slidy2 (interferes with dynamic documents)
 
@@ -46,17 +87,12 @@
 
 * A better uiSideBySide() system
 
-* Something similar to runExample() & runGist() in shiny
-
 * Move the definition of `!` here from SciViews? Or put in svMisc?
-
-* In shiny, when ui.R or server.R is updated, the app is also updated. Do the
-  same here?
   
 * Add an option(dynamic.trace = TRUE) to trace calls to dynamicXXX() functions.
 
-* In presentation or screencast mode: have a series of premared snippets to help
-  construct the SciViews Rdoc in live.
+* In presentation or screencast mode: have a series of prepared snippets to help
+  construct the SciViews doc in live.
 
 * To use Ubuntu and Ubuntu mono on a HTML page, add at the beginning og head section:
   <link href='http://fonts.googleapis.com/css?family=Ubuntu:400,400italic,700,700italic|Ubuntu+Mono:400,400italic,700,700italic&subset=latin,greek,latin-ext' rel='stylesheet' type='text/css'>
\ No newline at end of file

Modified: pkg/svDoc/man/asciidoc.Rd
===================================================================
--- pkg/svDoc/man/asciidoc.Rd	2013-01-11 15:31:12 UTC (rev 511)
+++ pkg/svDoc/man/asciidoc.Rd	2013-01-11 17:28:27 UTC (rev 512)
@@ -1,8 +1,9 @@
 \name{asciidoc}
 \alias{svDocToRnw}
-\alias{svDocConvert}
+\alias{svDocRender}
 \alias{svDocThemes}
 \alias{render...}
+\alias{print.renderer}
 
 \title{ Transform SciViews docs into R noweb or HTML files }
 \description{
@@ -14,10 +15,11 @@
 
 \usage{
 svDocToRnw(svDocFile, RnwFile, encoding)
-svDocConvert(svDocFile, theme, format, show.it, figs.dir, keep.RnwFile,
+svDocRender(svDocFile, theme, format, show.it, figs.dir, keep.RnwFile,
     keep.TxtFile, encoding, asciidoc)
 svDocThemes()
 render...(svDocFile, encoding)
+\method{print}{renderer}(x, \dots)
 }
 
 \arguments{
@@ -43,14 +45,20 @@
     end? }
   \item{asciidoc}{ path to the asciidoc Python script; By default, the version
     included in this package is used. }
+  \item{x}{ a renderer object. }
+  \item{\dots}{ further arguments passed to the \code{print()} method (not used
+    yet). }
 }
 
 \value{
   The text of the R noweb data is returned invisibly by \code{svDocToRnw()}.
-  \code{NULL} is returned by \code{svDocConvert()} (this function is invoked for
+  \code{NULL} is returned by \code{svDocRender()} (this function is invoked for
   its side effect). \code{svDocThemes()} returns the list of themes
   available for your HTML documents. Finally, \code{render...()} is a convenient
-  function to automatically build a SciViews document.
+  function to automatically build a SciViews document. It is also a renderer
+  object with a \code{print()} method that indeed runs it. So, you can type
+  just \code{render...} and it has the same effect as \code{render...()} at the
+  prompt or as a command to Rscript (useful to simplify scripting of svDoc).
 }
 
 \details{

Modified: pkg/svDoc/man/header.Rd
===================================================================
--- pkg/svDoc/man/header.Rd	2013-01-11 15:31:12 UTC (rev 511)
+++ pkg/svDoc/man/header.Rd	2013-01-11 17:28:27 UTC (rev 512)
@@ -16,7 +16,7 @@
 header(title, author = NULL, email = NULL, revnumber = NULL, revdate = NULL,
     revremark = NULL, copyright = "cc-by", encoding = "UTF-8", lang = "en",
     pagetitle = NULL, description = "SciViews document", keywords = NULL,
-    theme = "sciviews", max.width = 640, width = NULL,
+    format = NULL, theme = "sciviews", max.width = 640, width = NULL,
     toc = c("top", "side", "manual", "none"), toc.title = NULL, toclevels = 2,
     numbered = TRUE, data.uri = TRUE, frame = "topbot", grid = "rows",
     align = "center", halign = "center", pygments = FALSE, slidefontsizeadjust = 0,
@@ -57,7 +57,11 @@
     to use in the head section of the HTML document. If \code{NULL}, it is
     omitted. }
   \item{keywords}{ a character string with one or more keywords to use in the
-    head section of the HTML document. If \code{NULL}, it is omitted. } 
+    head section of the HTML document. If \code{NULL}, it is omitted. }
+  \item{format}{ export format to use. Either \code{"html"}, \code{"html4"},
+    \code{"html5"}, \code{"slidy"}, \code{"wordpress"}, \code{"docbook"},
+    \code{"docbook45"}, or \code{"latex"}
+    (see the AsciiDoc man page). }
   \item{theme}{ the theme to use with the Asciidoc HTML file. By default, it is
     \code{"SciViews"}. }
   \item{max.width}{ the maximum width of the page, in pixels or in percent.



More information about the Sciviews-commits mailing list