r-lib / roxygen2

Generate R package documentation from inline R comments
https://roxygen2.r-lib.org
Other
597 stars 234 forks source link

Is there a functionality to check if the roxygen declarations are corresponding to the functions? #1660

Open vertesy opened 2 months ago

vertesy commented 2 months ago

Hey, thank you for this great package, I use it when I'm writing my own packages.

Is there a functionality to check if the roxygen declarations are corresponding to the functions, in. a long file of many function declarations?

I want to check :

Thank you! Abel

olivroy commented 1 month ago

devtools::check_man()?

vertesy commented 1 month ago

Thank you so much, that works really well!

vertesy commented 1 month ago

On a second thought, after using it:

This function does the job, but not most conveniently. If a package has multiple R scripts, then you have to search through all of them to find where is that function declared and in which lines is the argument declaration missing.

Some of the other devtools functions, like document(), give you a direct clickable link in the console so that you can quickly jump to the problematic section of your code, if I recall correctly. (Unfortunately that does not check for missing argument declarations, only works for empty param declarations @ param _nothing follows_, as far as I know)

ℹ Updating PackageTools documentation
Writing [NAMESPACE](google.com)
ℹ Loading PackageTools
✖ [PackageTools.R:30](google.com): @param requires two parts: an argument name and a description.
Writing NAMESPACE

Alternatively, some functionality that would automatically place just the empty arguments @param missin wherever it's not declared would be also quite convenient.

If anyone knows about such, please let me know. Thank you.

vertesy commented 1 month ago

Also, I spent 2+ hours to make devtools::check_man() work for one of my packages, Seurat.utils.

> devtools::check_man("~/GitHub/Packages/Seurat.utils")
ℹ Updating Seurat.utils documentation
ℹ Loading Seurat.utils
ℹ Checking documentation...
Error in gzfile(file, "rb") : cannot open the connection
> rlang::last_trace()
<error/rlang_error>
Error in `package_file()`:
! /GitHub/Packages/Seurat.utils is not a directory.
---
Backtrace:
    ▆
 1. └─devtools::check_man("/GitHub/Packages/Seurat.utils")
 2.   └─devtools::as.package(pkg)
 3.     └─devtools::package_file(path = x)
Run rlang::last_trace(drop = FALSE) to see 2 hidden frames.

Admittedly, the package is not in the best shape, but that's exactly why I need a robust helper tool for.