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

vt_scrape_function_editors does not play nicely w/ @include roxy block #142

Open
mariev opened this issue May 12, 2021 · 2 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@mariev
Copy link
Collaborator

mariev commented May 12, 2021

When evaluating function author table for {scharpbama}, running into issue with file conditions_base.R due to the first line structure

conditions_base.R:

#' @include reexport-scharputils.R
NULL

evaluates to:

> vt_scrape_function_editors(tags = c("editor", "editDate"))

Error: NULL/deprecated functions must have a title.
Review file `C:/Users/mvendett/Documents/Github/scharpbama/R/conditions_base.R`, line 2
@mariev mariev added the bug Something isn't working label May 12, 2021
@mariev
Copy link
Collaborator Author

mariev commented May 12, 2021

the error message was very helpful! 👍 👍 👍

@mariev mariev changed the title vt_scrape_function_editors does not place nicely w/ @include roxy block vt_scrape_function_editors does not play nicely w/ @include roxy block May 12, 2021
@mariev
Copy link
Collaborator Author

mariev commented May 12, 2021

digging into this a bit further, it looks like orphan #' @include + NULL are expected to have a #' @title line i.e.

  withr::with_tempdir({

    ## test setup
    captured_output <- capture.output({vt_create_package(open = FALSE)})
    usethis::proj_set(force = TRUE)
    usethis::use_r("hello_world.R", open = FALSE)

    writeLines(c(
      "#' @title placeholder",
      "#' @name placeholder",
      "#' @include some-other-file.R",
      "NULL",
      "",
      "#' A function to greet someone",
      "#' @param name someone's name",
      "#' @editor An author",
      "#' @editDate 2021-01-01",
      "#' @return text greeting",
      "#' @export",
      " hello_world <- function(name){",
      "   paste(\"Hello \", name)",
      "}"
    ), file.path(usethis::proj_get(), "R", "hello_world.R"))
    testthat::expect_equal(vt_scrape_function_editors(tags = c("editor", "editDate")),
                 data.frame(functions = c("hello_world"),
                            editor = c("An author"),
                            editDate = c("2021-01-01"),
                            stringsAsFactors = FALSE))
  })

  withr::with_tempdir({

    ## test setup
    captured_output <- capture.output({vt_create_package(open = FALSE)})
    usethis::proj_set(force = TRUE)
    usethis::use_r("hello_world.R", open = FALSE)

    writeLines(c(
      "#' @include some-other-file.R",
      "NULL",
      "",
      "#' A function to greet someone",
      "#' @param name someone's name",
      "#' @editor An author",
      "#' @editDate 2021-01-01",
      "#' @return text greeting",
      "#' @export",
      " hello_world <- function(name){",
      "   paste(\"Hello \", name)",
      "}"
    ), file.path(usethis::proj_get(), "R", "hello_world.R"))

    testthat::expect_error(
      vt_scrape_function_editors(tags = c("editor", "editDate"))
      )
  })

while I can certainly add the extra tags when coming across this internally, my understanding is that the firstscenario is not the norm when reordering the collate field via roxygen2 (note that only @title is needed for vt_scrape_function_editors, but @name is needed to avoid devtools::check warning when @title is used.... 🙄 )

@thebioengineer what do you think use case should be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants