File: namespace.R

package info (click to toggle)
r-cran-usethis 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,228 kB
  • sloc: sh: 26; makefile: 17; cpp: 6; ansic: 3
file content (22 lines) | stat: -rw-r--r-- 820 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
22
#' Use a basic `NAMESPACE`
#'
#' If `roxygen` is `TRUE` generates an empty `NAMESPACE` that exports nothing;
#' you'll need to explicitly export functions with `@export`. If `roxygen`
#' is `FALSE`, generates a default `NAMESPACE` that exports all functions
#' except those that start with `.`.
#'
#' @param roxygen Do you plan to manage `NAMESPACE` with roxygen2?
#' @seealso The [namespace
#'   chapter](https://r-pkgs.org/dependencies-mindset-background.html#sec-dependencies-namespace)
#'   of [R Packages](https://r-pkgs.org).
#' @export
use_namespace <- function(roxygen = TRUE) {
  check_is_package("use_namespace()")

  path <- proj_path("NAMESPACE")
  if (roxygen) {
    write_over(path, c("# Generated by roxygen2: do not edit by hand", ""))
  } else {
    write_over(path, 'exportPattern("^[^\\\\.]")')
  }
}