Can `.envir` be used to autolink exported functions in a not loaded package in `cli_code()`?

Open
#692 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
r
Domain
tooling

Research direction

Start with cli::cli_code() and the .envir argument, using pkgdown::check_pkgdown and its environment as the reproducing case. Investigate how exported functions are resolved for autolinking when pkgdown is not loaded; done means the exported as_pkgdown() reference is linked without requiring the package to remain loaded.

Written by the indexing model from the issue text.

Description

feature
cli::cli_code(format(pkgdown::check_pkgdown))

If package is not loaded

image

Note that as_pkgdown() is exported by pkgdown. So I was wondering if there was another solution to autolink as_pkgdown() than to load the package?

Using

cli::cli_code(format(pkgdown::check_pkgdown), .envir = environment(pkgdown::check_pkgdown))

doesn't solve it.

Or is there a way to temporarily load the package for cli code and unloading immediately?

After library(pkgdown), I get what I'd like

image

Dominant language
R
Stars
726
Forks
94
Avg merge
3h 35m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/cli

All issues in r-lib/cli

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.