title: how can I add an roxygen @export all functions in a package
body: <p>I am taking over an existing package. The package was written with .Rd documentation before R required functions to be explicitly exported.</p>
  
  <p>My first step was to convert the documentation to roxygen using <a href="http://cran.r-project.org/web/packages/Rd2roxygen/" rel="nofollow">Rd2roxygen</a> (many many thanks to Yihui and Hadley for this package!).</p>
  
  <p>But now the package does not work because the functions are not exported. I would rather just export all functions by default. At this point it seems that my general approach would be to identify a regexp that can be found for each function ( <code>##' @return</code> would be a good target) and insert  <code>##' @export</code> in the line above it,</p>
  
  <p>In pseudocode:</p>
  
  <pre><code>for all files in the `R/` directory{
     for each line starting in `##' @return`{ 
        insert `##' @export` in the preceeding line
  }}
  </code></pre>
  
  <p>The result would be to replace:</p>
  
  <pre><code>##' @return something
  </code></pre>
  
  <p>with</p>
  
  <pre><code>##' @export
  ##' @return something that varies with each function
  </code></pre>
  
  <p>Getting a list of functions and adding them to NAMESPACE will not work because <code>devtools::document("mypackage")</code> will overwrite it if <code>@export</code> is not in the roxygen code above each function.</p>
  
  <p><strong>Question:</strong> what would be the most efficient way to add @export to the roxygen documentation for each function in the package?</p>
  
  <p>An even better alternative would be to parse the <code>NAMESPACE</code> and parse <code>export</code> and <code>method</code> statements accordingly.</p>