| Title: | File Paths Relative to Project Roots |
| Version: | 0.1.0 |
| Description: | Provides a set of helper functions for constructing file paths relative to the root of various types of projects, such as R packages, Git repositories, and more. File paths are specified with function arguments, or '$' to navigate into folders to specific files supported by auto-completion. |
| License: | MIT + file LICENSE |
| Imports: | rprojroot, utils |
| Suggests: | here, knitr, rmarkdown, testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| Encoding: | UTF-8 |
| URL: | https://github.com/mitchelloharawild/fromhere |
| BugReports: | https://github.com/mitchelloharawild/fromhere/issues |
| RoxygenNote: | 7.3.2.9000 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2025-01-14 08:18:32 UTC; mitchell |
| Author: | Mitchell O'Hara-Wild
|
| Maintainer: | Mitchell O'Hara-Wild <mail@mitchelloharawild.com> |
| Repository: | CRAN |
| Date/Publication: | 2025-01-15 10:50:03 UTC |
fromhere: File Paths Relative to Project Roots
Description
Provides a set of helper functions for constructing file paths relative to the root of various types of projects, such as R packages, Git repositories, and more. File paths are specified with function arguments, or '$' to navigate into folders to specific files supported by auto-completion.
Author(s)
Maintainer: Mitchell O'Hara-Wild mail@mitchelloharawild.com (ORCID)
See Also
Useful links:
Report bugs at https://github.com/mitchelloharawild/fromhere/issues
Create a File Path Relative to a Project Root
Description
These functions generate file paths relative to the root of a specific type of project.
They use criteria from rprojroot to locate the root directory and construct paths
using file.path().
Usage
from_here(...)
from_wd(...)
from_rproj(...)
from_r_package(...)
from_remake(...)
from_drake(...)
from_targets(...)
from_pkgdown(...)
from_renv(...)
from_projectile(...)
from_quarto(...)
from_git(...)
from_svn(...)
from_vcs(...)
from_testthat(...)
Arguments
... |
Character components of the relative file path. |
Details
Functions support two ways to specify paths: as function arguments
(e.g., from_r_package("path/to/file")) or using the $ operator
(e.g., from_r_package$path$to$file), which supports autocompletion.
The following from_* functions are available:
-
from_here: For paths relative to the{here}package's automatic project root. -
from_rproj: For R project directories. -
from_r_package: For R package directories. -
from_remake: For remake project directories. -
from_drake: For drake project directories. -
from_targets: For targets project directories. -
from_pkgdown: For pkgdown project directories. -
from_renv: For renv project directories. -
from_projectile: For Projectile project directories. -
from_quarto: For Quarto project directories. -
from_git: For Git repository root directories. -
from_svn: For SVN repository root directories. -
from_vcs: For generic version control root directories (Git or SVN). -
from_testthat: For testthat directories.
Value
A file path which allows further traversal with $ autocompletion.
See Also
Examples
# Construct a path from the current working directory
from_wd()
## Not run:
# Construct a path to a file in an R package
from_r_package("R", "my_file.R")
# Construct a path in a pkgdown project
from_pkgdown$docs$index.html
# Construct a path in a Git repository
from_git("src", "main.c")
## End(Not run)