[Roxygen-commits] r246 - in pkg: R sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 16 22:40:47 CEST 2010


Author: pcd
Date: 2010-07-16 22:40:47 +0200 (Fri, 16 Jul 2010)
New Revision: 246

Added:
   pkg/sandbox/REFERENCES.bib
   pkg/sandbox/bibtex-roclet.R
Modified:
   pkg/R/callgraph.R
Log:
bibtex roclet

Modified: pkg/R/callgraph.R
===================================================================
--- pkg/R/callgraph.R	2010-03-16 18:30:48 UTC (rev 245)
+++ pkg/R/callgraph.R	2010-07-16 20:40:47 UTC (rev 246)
@@ -5,7 +5,7 @@
 
 register.preref.parsers(parse.value,
                         'callGraphDepth',
-				'callGraphType')
+                        'callGraphType')
 
 register.preref.parsers(parse.toggle,
                         'callGraph',
@@ -245,6 +245,7 @@
   parse.callgraph.primitives <- function(key, expression)
     do.callgraph.primitives <<- TRUE
 
+  ## oh, yeah; we meant to do a parse.number once upon a time.
   parse.callgraph.depth <- function(key, expression) {
     depth <- tryCatch(as.numeric(expression),
                       warning=function(e) NULL,

Added: pkg/sandbox/REFERENCES.bib
===================================================================
--- pkg/sandbox/REFERENCES.bib	                        (rev 0)
+++ pkg/sandbox/REFERENCES.bib	2010-07-16 20:40:47 UTC (rev 246)
@@ -0,0 +1,17 @@
+ at Book{frankfurt:2010,
+  ALTauthor =       {},
+  editor =       {Harry G. Frankfurt},
+  title =        {On Bullshit},
+  publisher =    {Princeton},
+  year =         {2008},
+  OPTkey =       {},
+  OPTvolume =    {},
+  OPTnumber =    {},
+  OPTseries =    {},
+  OPTaddress =   {},
+  OPTedition =   {},
+  OPTmonth =     {},
+  OPTnote =      {},
+  OPTannote =    {}
+}
+

Added: pkg/sandbox/bibtex-roclet.R
===================================================================
--- pkg/sandbox/bibtex-roclet.R	                        (rev 0)
+++ pkg/sandbox/bibtex-roclet.R	2010-07-16 20:40:47 UTC (rev 246)
@@ -0,0 +1,54 @@
+source('../R/roxygen.R')
+source('../R/functional.R')
+source('../R/list.R')
+source('../R/memoize.R')
+source('../R/parse.R')
+source('../R/string.R')
+source('../R/roclet.R')
+source('../R/namespace.R')
+source('../R/collate.R')
+source('../R/Rd.R')
+source('../R/callgraph.R')
+library(bibtex)
+
+debug <- function(..., print=str)
+  print(list(...))
+
+register.preref.parsers(parse.name,
+                        'cite',
+                        'bibliography')
+
+make.bibtex.roclet <- function() {
+  roclet <- make.roclet()
+  roclet$bibliography <- 'REFERENCES.bib'
+  roclet$citationList <- NULL
+
+  ## candidate for pre.files
+  parse.bibliography <- function(key, expression)
+    roclet$bibliography <- expression
+
+  parse.cite <- function(key, expression) {
+    if (is.nil(roclet$citationList))
+      roclet$citationList <- read.bib(file=roclet$bibliography)
+    for (citation in roclet$citationList) {
+      if (attributes(citation)$key == expression) {
+        cat(sprintf("%s. %s. %s. %s.\n",
+                    citation$editor,
+                    citation$title,
+                    citation$publisher,
+                    citation$year))
+        return()
+      }
+    }
+    warning(sprintf("bibtex: unknown key: %s", expression),
+            call.=FALSE,
+            immediate.=TRUE)
+  }
+
+  roclet$register.parser('cite', parse.cite)
+  roclet
+}
+
+make.bibtex.roclet()$parse.parsed(parse.text("#' @cite frankfurt:2010",
+                                             "#' @cite non-existent-key",
+                                             "NA"))



More information about the Roxygen-commits mailing list