File: missing-s3.R

package info (click to toggle)
r-cran-devtools 2.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,340 kB
  • sloc: sh: 15; makefile: 5
file content (21 lines) | stat: -rw-r--r-- 602 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#' Find missing s3 exports.
#'
#' The method is heuristic - looking for objs with a period in their name.
#'
#' @template devtools
#' @export
missing_s3 <- function(pkg = ".") {
  pkg <- as.package(pkg)
  loaded <- load_all(pkg$path)

  # Find all S3 methods in package
  objs <- ls(envir = loaded$env)
  is_s3 <- function(x) roxygen2::is_s3_method(x, env = loaded$env)
  s3_objs <- Filter(is_s3, objs)

  # Find all S3 methods in NAMESPACE
  ns <- pkgload::parse_ns_file(pkg$path)
  exports <- paste(ns$S3methods[, 1], ns$S3methods[, 2], sep = ".")

  setdiff(s3_objs, exports)
}