scope: Make package dependencies explicit

View source: R/scope.R

scopeR Documentation

Make package dependencies explicit

Description

Parses the input, and explicitly adds namespace access where appropriate.

Usage

scope(x, envir = caller_env(), ...)

## Default S3 method:
scope(x, envir = caller_env(), ...)

## S3 method for class 'character'
scope(x, envir = caller_env(), ...)

## S3 method for class ''function''
scope(
  x,
  envir = get_env(x) %||% caller_env(),
  useSource = TRUE,
  inPackage = TRUE,
  ...
)

## S3 method for class 'call'
scope(x, envir = caller_env(), ...)

## S3 method for class 'quosure'
scope(x, envir = quo_get_env(x) %||% caller_env(), ...)

Arguments

x

A character vector of parseable code, a call, a quosure, or a function.

envir

An environment in which the expression should be evaluated. Defaults to the enclosing environment if x is a function, otherwise the calling environment.

Value

Returns a [ParseTreeScoper] object which prints the modified code.

Examples


# Unchanged
scope(1)
scope("a")

# Modified
library(colonoscopy)
scope(scope)

TylerGrantSmith/colonoscopy documentation built on Aug. 22, 2022, 11:58 p.m.