diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cebbf36..db58706 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,14 +28,14 @@ repos: hooks: - id: air-format name: air format - entry: air format . + entry: RcppTskit/tools/run-local-tool.sh air format . language: system pass_filenames: false files: '\.(R|Rmd|rmd|qmd|Qmd)$' - id: jarl-lint name: jarl lint - entry: jarl check . + entry: RcppTskit/tools/run-local-tool.sh jarl check . language: system pass_filenames: false files: '\.(R|Rmd|rmd|qmd|Qmd)$' diff --git a/README.md b/README.md index 7f93659..db62a43 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ To install the published release from [CRAN](https://cran.r-project.org) use: # https://github.com/HighlanderLab/RcppTskit/issues/14 # https://github.com/HighlanderLab/RcppTskit/issues/45 # install.packages("RcppTskit") +# vignette("RcppTskit_intro") ``` To install the latest development version (possibly unstable!) from @@ -99,10 +100,14 @@ https://mac.r-project.org/tools for macOS tools. # remotes::install_github("HighlanderLab/RcppTskit/RcppTskit") # Main branch -remotes::install_github("HighlanderLab/RcppTskit/RcppTskit@main") +remotes::install_github("HighlanderLab/RcppTskit/RcppTskit@main", + build_vignettes=TRUE) # Development branch -remotes::install_github("HighlanderLab/RcppTskit/RcppTskit@devel") +remotes::install_github("HighlanderLab/RcppTskit/RcppTskit@devel", + build_vignettes=TRUE) + +vignette("RcppTskit_intro") ``` ## Development diff --git a/RcppTskit/R/RcppTskit-package.R b/RcppTskit/R/RcppTskit-package.R index d3d4a17..6fe19fb 100644 --- a/RcppTskit/R/RcppTskit-package.R +++ b/RcppTskit/R/RcppTskit-package.R @@ -24,7 +24,7 @@ #' @importFrom reticulate import is_py_object py_module_available py_require #' #' @examples -#' vignette(package="RcppTskit") +#' vignette("RcppTskit_intro") "_PACKAGE" #' Provide an inline plugin so we can call the tskit C API with functions like diff --git a/RcppTskit/man/RcppTskit-package.Rd b/RcppTskit/man/RcppTskit-package.Rd index d763066..b601dbf 100644 --- a/RcppTskit/man/RcppTskit-package.Rd +++ b/RcppTskit/man/RcppTskit-package.Rd @@ -22,7 +22,7 @@ work with tree sequences. Currently, \code{RcppTskit} provides a limited set of R functions because the Python API and \code{reticulate} already covers most needs. } \examples{ -vignette(package="RcppTskit") +vignette("RcppTskit_intro") } \seealso{ Useful links: diff --git a/RcppTskit/tools/run-local-tool.sh b/RcppTskit/tools/run-local-tool.sh new file mode 100755 index 0000000..b9238c1 --- /dev/null +++ b/RcppTskit/tools/run-local-tool.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env sh +set -eu + +if [ "$#" -lt 1 ]; then + echo "Usage: $0 [args...]" >&2 + exit 2 +fi + +tool="$1" +shift + +if command -v "$tool" >/dev/null 2>&1; then + exec "$tool" "$@" +fi + +# Follow project guidance by checking user-local bin directories. +if [ -n "${HOME:-}" ]; then + PATH="${HOME}/.local/bin:${HOME}/bin:${PATH}" + export PATH + if command -v "$tool" >/dev/null 2>&1; then + exec "$tool" "$@" + fi +fi + +# As a last resort, query the user's login shell PATH. +if [ -n "${SHELL:-}" ] && [ -x "${SHELL:-}" ]; then + resolved="$("${SHELL}" -lc "command -v \"$tool\"" 2>/dev/null || true)" + if [ -n "$resolved" ] && [ -x "$resolved" ]; then + exec "$resolved" "$@" + fi +fi + +echo "Executable '$tool' not found on PATH." >&2 +echo "Install '$tool' and ensure your shell PATH exports it." >&2 +exit 3 diff --git a/RcppTskit/vignettes/RcppTskit_intro.qmd b/RcppTskit/vignettes/RcppTskit_intro.qmd index 2fd159b..1870fa7 100644 --- a/RcppTskit/vignettes/RcppTskit_intro.qmd +++ b/RcppTskit/vignettes/RcppTskit_intro.qmd @@ -141,21 +141,20 @@ to record a tree sequence in a multi-generation simulation with many individuals Given the current tree sequence ecosystem, the aims of the `RcppTskit` package are to provide an easy-to-install R package -that supports users in four typical cases. +that supports users in four typical cases of working with tree sequences +and table collection. The authors are open to expanding this scope of `RcppTskit` depending on user demand and engagement. The four typical cases are: -1. Load a tree sequence[^ts_and_tc_note] into R and summarise it, +1. Load a tree sequence into R and summarise it, -2. Pass a tree sequence[^ts_and_tc_note] between R and reticulate or standard Python, +2. Pass a tree sequence between R and reticulate or standard Python, 3. Call the `tskit` C API from C++ in an R session or script, and 4. Call the `tskit` C API from C++ in another R package. -[^ts_and_tc_note]: Both tree sequence and table collection types are supported. - Examples for all of these cases are provided below after we describe the implemented data and class model. @@ -213,7 +212,7 @@ if (!test) { } ``` -### 1) Load a tree sequence[^ts_and_tc_note] into R and summarise it +### 1) Load a tree sequence into R and summarise it ```{r} #| label: use_case_1 @@ -239,7 +238,7 @@ ts2 <- tc$tree_sequence() help(package = "RcppTskit") ``` -### 2) Pass a tree sequence[^ts_and_tc_note] between R and reticulate or standard Python +### 2) Pass a tree sequence between R and reticulate or standard Python ```{r} #| label: use_case_2