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

lifecycle badge image not found on quarto site #275

Open
rbcavanaugh opened this issue Apr 10, 2024 · 9 comments
Open

lifecycle badge image not found on quarto site #275

rbcavanaugh opened this issue Apr 10, 2024 · 9 comments

Comments

@rbcavanaugh
Copy link

If I have the following in my function roxygen2 documentation

#' Creates a temporary table from a local data frame or tibble
#'
#' `r lifecycle::badge('experimental')`

I get the following on the generated reference page for the function:

image

(link to function: https://github.com/roux-ohdsi/allofus/blob/main/R/aou_temp_tables.R and site: https://roux-ohdsi.github.io/allofus/man/aou_create_temp_table.html)

@etiennebacher

This comment was marked as outdated.

@etiennebacher
Copy link
Owner

I see, the link correctly appears in the qmd file but it links to the badge that is located in man/figures and this badge is not imported in the docs folder.

@vincentarelbundock
Copy link
Collaborator

Can we swap the lifecycle line with some kind of conditional link? It feels silly to import another package and build complicated backend code just to insert an image and a link in the docs...

@etiennebacher
Copy link
Owner

etiennebacher commented Apr 11, 2024

IIUC we wouldn't have to import lifecycle, we would just need to copy all the SVG badges from man/figures (I guess those are created by devtools::document()) to docs/man/figures. We don't have to use any functionalities from lifecycle itself

@vincentarelbundock
Copy link
Collaborator

I was thinking there must exist a one-liner to load an image from a website without altdoc having to do anything at all.

But I've not tried to find one yet...

@vincentarelbundock
Copy link
Collaborator

If that one-line doesn't exist or is too complicated, we should support a more general interface to inserting images in documentation.

I just think we should resist the temptation to replicate every possible tidyverse functionality with dedicated arguments and backend code, and try to think of more general ways to do things.

@eitsupi
Copy link
Contributor

eitsupi commented Oct 6, 2024

Does this have anything to do with tidyverse?
This actually generates the following Rd code, which has no package dependencies.
I infer from this that the \figure tag is for linking to images in man/figures (i.e., a specification in the Rd file that has nothing to do with the tidyverse).

\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}

See also: https://rstudio.github.io/r-manuals/r-exts/Writing-R-documentation-files.html#figures

The files containing the figures should be stored in the directory man/figures. Files with extensions .jpg, .jpeg, .pdf, .png and .svg from that directory will be copied to the help/figures directory at install time. (Figures in PDF format will not display in most HTML browsers, but might be the best choice in reference manuals.) Specify the filename relative to man/figures in the \figure directive.

man/figures seems to be commonly used to put files related to images.
https://github.com/search?q=org%3Acran%20path%3Aman%2Ffigures&type=code

Related to r-lib/pkgdown#1787

@eitsupi
Copy link
Contributor

eitsupi commented Oct 6, 2024

Apparently, image handling in the R package is more cumbersome than one might imagine.

Images in man/figures will be moved to help/figures after installation, so the Rd2HTML() function will use the relative path ../help/figures for the \figure tag of Rd files.

pkgdown copies all normal images to reference/figures/ and rewrites all tags of HTML files.

Only the logo is specially copied to the top level.
https://github.com/r-lib/pkgdown/blob/0cb9d38d1dc25946f01ee7500be9665985d8784e/R/build-logo.R

The easiest workaround is to copy man/figures to help/figures as well, but in this case, if there are references to man/figures from README, etc., the same image will exist in two places. (This may not be a big problem, just a waste of space.)

Perhaps a process needs to be added to rewrite the links to help/figures to man/figures for html files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants