Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias collision when documenting package which contains a function with the same name. #1160

Closed
brendanf opened this issue Oct 14, 2020 · 6 comments · Fixed by #1549
Closed
Labels
bug an unexpected problem or unintended behavior rd ✍️
Milestone

Comments

@brendanf
Copy link

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 = "fake@madeup.org", 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{fake@madeup.org}

}

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’

@hadley
Copy link
Member

hadley commented Oct 30, 2020

Use @aliases hello-package to override

@maelle
Copy link
Contributor

maelle commented Nov 4, 2020

Came here via r-lib/pkgdown#1414

@maelle
Copy link
Contributor

maelle commented Nov 4, 2020

So should the fix be documentation of the tip above or something else?

@hadley
Copy link
Member

hadley commented Nov 18, 2020

I think it should be fixed in roxygen2.

@ellessenne
Copy link

Hi all,
I also just experienced the same issue and solved it by following David's comment here: tidymodels/hardhat#130 (comment)

@hadley
Copy link
Member

hadley commented Nov 21, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior rd ✍️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants