roxygen2
roxygen2 copied to clipboard
Alias collision when documenting package which contains a function with the same name.
There seems to have been a reversion sometime since this Stack Exchange answer was given; now when I make a new package hello using
hello/R/hello.R:
#' hello
#'
#' This is a mostly empty package to learn roxygen documentation.
#'
#' Hello allows me to learn how to write documentation in comment blocks
#' co-located with code.
"_PACKAGE"
#' hello
#'
#' This function returns "Hello, world!".
#' @export
#' @examples
#' hello()
hello <- function() {
print("Hello, world!")
}
and hello/DESCRIPTION:
Package: hello
Type: Package
Title: A mostly empty package
Version: 0.1
Date: 2016-06-21
Authors@R: person("Some", "Person", email = "[email protected]", role = c("aut", "cre"))
Description: More about what it does (maybe more than one line)
License: MIT
LazyData: TRUE
RoxygenNote: 7.1.0
and then build documentation, I get the following hello/man/hello-package.Rd:
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hello.R
\docType{package}
\name{hello-package}
\alias{hello}
\alias{hello-package}
\title{hello}
\description{
This is a mostly empty package to learn roxygen documentation.
}
\details{
Hello allows me to learn how to write documentation in comment blocks
co-located with code.
}
\author{
\strong{Maintainer}: Some Person \email{[email protected]}
}
The \alias{hello} line conflicts with documentation for hello(), resulting in the R CMD check warning Rd files with duplicated alias 'hello': ‘hello-package.Rd’ ‘hello.Rd’
Use @aliases hello-package to override
Came here via https://github.com/r-lib/pkgdown/issues/1414
So should the fix be documentation of the tip above or something else?
I think it should be fixed in roxygen2.
Hi all, I also just experienced the same issue and solved it by following David's comment here: https://github.com/tidymodels/hardhat/issues/130#issuecomment-622438758
Fixing this is going to require some thought, because we currently add the default aliases in object_defaults.package, where the full set of aliases used by the package isn't know.
I think we'd need to add something to roclet_process.roclet_rd that gets all aliases across topics, and then adds aliases to the package doc if they're otherwise missing.