[Rcpp-commits] r4274 - in pkg/Rcpp: . inst src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Feb 28 21:14:48 CET 2013
Author: jjallaire
Date: 2013-02-28 21:14:48 +0100 (Thu, 28 Feb 2013)
New Revision: 4274
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/NEWS.Rd
pkg/Rcpp/src/attributes.cpp
Log:
standalone roxygen chunks (e.g. to document a class) are now transposed into RcppExports.R
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2013-02-27 19:57:54 UTC (rev 4273)
+++ pkg/Rcpp/ChangeLog 2013-02-28 20:14:48 UTC (rev 4274)
@@ -1,3 +1,8 @@
+2013-02-28 JJ Allaire <jj at rstudio.org>
+
+ * src/attributes.cpp: standalone roxygen chunks (e.g. to document
+ a class) are now transposed into RcppExports.R
+
2013-02-27 JJ Allaire <jj at rstudio.org>
* R/Rcpp.package.skeleton.R: eliminated spurious empty hello world
Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd 2013-02-27 19:57:54 UTC (rev 4273)
+++ pkg/Rcpp/inst/NEWS.Rd 2013-02-28 20:14:48 UTC (rev 4274)
@@ -13,6 +13,8 @@
\item Changes in Rcpp attributes:
\itemize{
\item Rcpp modules can now be used with \code{sourceCpp}
+ \item Standalone roxygen chunks (e.g. to document a class) are now
+ transposed into RcppExports.R
\item Added \code{Rcpp::plugins} attribute for binding
directly to inline plugins. Plugins can be registered using
the new \code{registerPlugin} function.
Modified: pkg/Rcpp/src/attributes.cpp
===================================================================
--- pkg/Rcpp/src/attributes.cpp 2013-02-27 19:57:54 UTC (rev 4273)
+++ pkg/Rcpp/src/attributes.cpp 2013-02-28 20:14:48 UTC (rev 4274)
@@ -264,8 +264,10 @@
virtual const_iterator end() const = 0;
virtual const std::vector<std::string>& modules() const = 0;
-
- virtual bool hasAttributesOrModules() const = 0;
+
+ virtual const std::vector<std::vector<std::string> >& roxygenChunks() const = 0;
+
+ virtual bool hasGeneratorOutput() const = 0;
};
@@ -320,9 +322,15 @@
return modules_;
}
- virtual bool hasAttributesOrModules() const
+ virtual const std::vector<std::vector<std::string> >& roxygenChunks() const {
+ return roxygenChunks_;
+ }
+
+ virtual bool hasGeneratorOutput() const
{
- return !attributes_.empty() || !modules_.empty();
+ return !attributes_.empty() ||
+ !modules_.empty() ||
+ !roxygenChunks_.empty();
}
virtual bool hasInterface(const std::string& name) const {
@@ -375,6 +383,7 @@
std::vector<Attribute> attributes_;
std::vector<std::string> modules_;
std::vector<std::string> embeddedR_;
+ std::vector<std::vector<std::string> > roxygenChunks_;
std::vector<std::string> roxygenBuffer_;
};
@@ -864,6 +873,12 @@
std::string roxLine = "#" + line.substr(2);
roxygenBuffer_.push_back(roxLine);
}
+
+ // a non-roxygen line causes us to clear the roxygen buffer
+ else if (!roxygenBuffer_.empty()) {
+ roxygenChunks_.push_back(roxygenBuffer_);
+ roxygenBuffer_.clear();
+ }
}
}
@@ -1779,6 +1794,17 @@
const SourceFileAttributes& attributes,
bool verbose) {
+ // write standalone roxygen chunks
+ const std::vector<std::vector<std::string> >& roxygenChunks =
+ attributes.roxygenChunks();
+ for (std::size_t i = 0; i<roxygenChunks.size(); i++) {
+ const std::vector<std::string>& chunk = roxygenChunks[i];
+ for (std::size_t l = 0; l < chunk.size(); l++)
+ ostr() << chunk[l] << std::endl;
+ ostr() << "NULL" << std::endl << std::endl;
+ }
+
+ // write exported functions
if (attributes.hasInterface(kInterfaceR)) {
// process each attribute
for(std::vector<Attribute>::const_iterator
@@ -2717,10 +2743,10 @@
std::set<std::string> dependsAttribs;
for (std::size_t i=0; i<cppFiles.size(); i++) {
- // parse attributes (continue if there are none)
+ // parse file (continue if there is no generator output)
std::string cppFile = cppFiles[i];
SourceFileAttributesParser attributes(cppFile);
- if (!attributes.hasAttributesOrModules())
+ if (!attributes.hasGeneratorOutput())
continue;
// confirm we have attributes
More information about the Rcpp-commits
mailing list