Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a vectorized wrapper for xfun::relative_path #1091

Merged
merged 2 commits into from
Mar 4, 2021

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Mar 4, 2021

To handle several inputs in render_book(input=). Currently it seems to work but we have warnings thrown in xfun::relative_path

Warning messages:
1: In if ((n1 <- nchar(p)) == 0) return(x) :
  the condition has length > 1 and only the first element will be used
2: In if (is_sub_path(p, d, n2)) { :
  the condition has length > 1 and only the first element will be used
3: In if (p2 == "") p2 = "." :
  the condition has length > 1 and only the first element will be used

Reported in #1090

Other solution would be to make xfun functions vectorized. @yihui would that be better ?

This type of situation make me feels we are trying to recreate / maintain / tests some functionality we could get elsewhere : fs package is rather low level with no dependency and could help power all the path handling in the packages. Just throwing the idea in case this is a project we want to tackle.

@cderv cderv requested a review from yihui March 4, 2021 10:02
Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other solution would be to make xfun functions vectorized.

Yes. I'll merge this PR for now and think about it later.

This type of situation make me feels we are trying to recreate / maintain / tests some functionality we could get elsewhere

It's always a trade-off between introducing new dependencies and maintaining one's own code. If the latter is not too complicated, I tend to go the latter way. fs does contain a huge set of functions about file paths, but I only need a very small subset of it.

Thanks!

@yihui yihui merged commit 6ae8ead into master Mar 4, 2021
@yihui yihui deleted the fix/multiple-input-1090 branch March 4, 2021 15:38
yihui added a commit to yihui/xfun that referenced this pull request Mar 5, 2021
@yihui
Copy link
Member

yihui commented Mar 11, 2021

FYI xfun::relative_path() can take a vector now (xfun v0.22 was released to CRAN last night).

clrpackages pushed a commit to clearlinux-pkgs/R-xfun that referenced this pull request Mar 16, 2021
Yihui Xie (22):
      use exit_call(), and return early if stringsAsFactors is already false
      clarify the title, since not all functions are written by me
      vectorize relative_path(): rstudio/bookdown#1091
      use tinytex::is_tinytex() since v0.30 is on CRAN now
      update license year
      don't override the env var R_LIBS_USER if it has been set
      read both ~/.Renviron and .Renviron
      factor out path_sep()
      if no package is left after ignoring specified packages, return early
      when rechecking packages, make sure their dependencies are installed
      add a function to help clean up a dir that contains binary packages built with an older major version of R
      always return the names of broken packages
      add functions to query Homebrew dependencies of R packages
      add a function `retry()` to retry calling a function for a number of times in case of errors
      also split package names by spaces, e.g., "pandoc pandoc-citeproc" -> c("pandoc", "pandoc-citeproc")
      use tools::write_PACKAGES() instead of write.dcf() (to also update PACKAGES.gz/.rds)
      fix rstudio/tinytex#286: increase the timeout to 3600 seconds in download_file()
      add a function sort_file() to sort text lines in a file
      the argument `FUN` was renamed to `fun` in `process_file()`; this is for consistency with other functions like retry() and exit_call(), but might be a breaking change (if that's the case, I may revert this change)
      factor out the code to read sysreqsdb.rds
      use known dependencies instead of querying every time
      CRAN release v0.22

christophe dervieux (1):
      typo in on.exit() help page
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants