Search code examples
rpackagelifecycleroxygen2r-usethis

How to remove duplicate package alias in autocreated pkgname-package.R?


I used lifecycle for the depreciated badge, which required me to use usethis::use_package_doc (I BELIEVE - this may not have been the function but I think it was). This resulted in a script myPkgName-package.R being created, and thus myPkgName-package.Rd after running devtools::document. The entire content of the R file are:

#' @keywords internal
"_PACKAGE"
## usethis namespace: start
#' @importFrom lifecycle deprecated
## usethis namespace: end
NULL

However the Rd file has (among other stuff):

\docType{package}
\name{myPkgName-package}
\alias{myPkgName}
\alias{myPkgName-package}

R CMD check for CRAN submission now hits a warning:

Rd files with duplicated alias 'myPkgName': 'myPkgName-package.Rd' 'myPkgName.Rd'

Does anyone know how to remove the myPkgName alias from myPkgName-package.R (and therefore from myPkgName-package.Rd)? I've tried various approaches with aliases in myPkgName-package.R, notably:

#' @aliases myPkgName-package
#' @aliases NULL

(not at the same time), and run devtools::document each time, which says

Updating myPkgName documentation

... but nothing changes in myPkgName-package.Rd. Does anyone know how to fix this? I've seen a few questions about this from various package maintainers but no official generic question on here, to be a focal point when others hit this issue.


Solution

  • See this answer and related links; simply follow Jenny's reprex.