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 'hex' match #6

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ find_imgpaths <- function(pkgnames) {
#' @return A vector of logo paths
find_logopaths <- function(imagepaths, pkgnames){
logopaths <- purrr::map2(imagepaths, pkgnames, function(x, pkg) {
logo_matches <- x[grepl("logo", x, ignore.case = TRUE)]
logo_matches <- x[grepl("hex|logo", x, ignore.case = TRUE)]

if (length(logo_matches) == 0 && length(x) > 0) {
choices <- c(basename(x), "None of the above")
Expand All @@ -73,7 +73,7 @@ find_logopaths <- function(imagepaths, pkgnames){
return(NA_character_)
}
})

unlist(logopaths)
}

Expand Down Expand Up @@ -140,11 +140,11 @@ make_missingLogos <- function(attached_pkgs, logopaths) {
if (!is.list(logoimgs)) {
logoimgs <- list(logoimgs)
}

imgpaths <- paste0(tempfile(), "_", pending, ".png")

purrr::walk2(logoimgs, imgpaths,
purrr::walk2(logoimgs, imgpaths,
\(x, y) magick::image_write(x, y))

as.list(imgpaths)
}
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ remotes::install_github("luisdva/hexsession")
With hexsession installed, we can create a self-contained HTML file with tiled hex logos for all loaded packages in a session. If a package does not have a logo bundled in `man/figures/` or if the image cannot be found easily, a generic-looking logo with the package name will be generated.

* svg files are internally converted to png
* If the images bundled with a package do not match 'logo', a users are prompted to specify which file to use.
* If the images bundled with a package do not match 'hex' or 'logo', or there are multiple possible options, users are prompted to specify which file to use.



Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ found easily, a generic-looking logo with the package name will be
generated.

- svg files are internally converted to png
- If the images bundled with a package do not match ‘logo’, a users are
prompted to specify which file to use.
- If the images bundled with a package do not match ‘hex’ or ‘logo’, or
there are multiple possible options, users are prompted to specify
which file to use.

For a given session with libraries loaded in addition to base packages:

Expand Down
Loading