DanChaltiel / autoimport

A toolbox to automatically generate @importFrom roxygen tags from R files.
https://danchaltiel.github.io/autoimport/
13 stars 2 forks source link

`autoimport()` tries to include R6 public methods as `@importFrom` #6

Closed cregouby closed 1 year ago

cregouby commented 1 year ago

Current situation

I've run autoimport() on the code in https://github.com/mlverse/tabnet and I get some unexpected insertion of R6 public methods as Roxygen #' @importFrom

Before autoimport()

After autoimport()

-autoimport() add erroneously import from functions from exotic libraries, messing up the NAMESPACE file and DESCRIPTION file image

Reproducible example

# git clone https://github.com/mlverse/tabnet
# cd tabnet
library(autoimport)
library(tidyverse)
autoimport(files = "R/sparsemax.R")
DanChaltiel commented 1 year ago

Yes, this is also a known limitation from utils::getSrcref(). As soon as something is recognized as a function it calls an @importFrom. I don't know how I could make a special case for R6 as this is not an inbuilt feature of R. I'm not even sure this is possible. Of course, I'd gladly accept a PR if you manage to find a solution.

BTW, thank you for your very nice and readable issues 👍

cregouby commented 1 year ago

Thanks !