alan-turing-institute / network-comparison

An R package implementing the NetEMD and NetDis network comparison measures
MIT License
14 stars 3 forks source link

Missing name error when running devtools::document() #112

Closed martintoreilly closed 6 years ago

martintoreilly commented 6 years ago

Problem

Running devtools::document() gives a "Missing name" error in RccpExports.R

> devtools::document()
Updating netdist documentation
Loading netdist
Writing NAMESPACE
Warning: RcppExports.R:31: Missing name
Writing counts_from_observations.Rd
Writing emd_fast_no_smoothing.Rd

Restarting R session...

Line 31 of RcppExports.R is a NULL underneath the Roxygen docstring for the add_element_kahan() C++ helper function in emd_fast_no_smoothing.cpp

Solution

Roxygen picks up any Roxygen docstrings (lines starting\\') from C++ functions and copies them to RcppExports.R, whether or not their associated functions are exported to R (using // [[Rcpp::export]] or exported from the package (using \\' @export). However, if the function is not actually exported then there will be no function call under the copied docstring in RcppExport.R, only NULL. As there is nothing indicating the function name, Roxygen will give a "Missing name" error when trying to generate a <function_name>.Rd file with the documentation from the docstring.

There are two options to fix this.

(1) Add a \\' @name <function_name> Roxygen keyword. This will give Roxygen the information it needs to name the <function_name>.Rd file, which will be created.

(2) Remove the docstrings from non-exported C++ functions or make them normal C++ comments instead.

We have done (2).