deepayan / r-refmans

1 stars 2 forks source link

Appearance of lifecycle badges #1

Open EllaKaye opened 3 months ago

EllaKaye commented 3 months ago

I just came across this project through this issue on the r-dev-day repo. I posted a comment there, but thought it might be useful to cross-post in this repo.

I had a quick flick through some of the manuals on https://deepayan.github.io/r-refmans/ and noted an issue. Lifecycle badges aren't rendered, e.g. at https://deepayan.github.io/r-refmans/dplyr.html#add_rownames. They appear as a small rectangle with a question mark in a blue box. These boxes are links and they resolve to various sections of the stages vignette in the lifecycle package. It would be nice if these HTML manual pages could show the badges properly, or at least have some other way of showing the text "lifecycle: experimental/stable/superseded/deprecated" as appropriate.

deepayan commented 3 months ago

Thanks for the report. This might be a little tricky; the contents of dplyr/man/figures/ will most likely not be available on CRAN, so it is not clear where the image can be obtained from. Embedding might be an option.

EllaKaye commented 3 months ago

I think an actual .svg image, as in dplyr/man/figures/, is probably less important from an information provided point-of-view than the text displayed on them, i.e. stating the phase of the lifecycle (and the text could still be hyperlinked to the appropriate part of the lifecycles vignette, though I don't know how tricky that would be). I don't know which would be harder in the context of creating these HTML pages, parsing that text or somehow embedding the images.

deepayan commented 3 months ago

I don't understand --- isn't that already being done? In both Firefox and Chrome, the alt text "[Deprecated]" is displayed and properly linked. Chrome shows a broken image icon, and Firefox doesn't even do that.

EllaKaye commented 3 months ago

I've only checked on Safari. What I described in my first comment is what I'm seeing in that browser.

deepayan commented 3 months ago

Ah, that seems to be a Safari bug/feature.

The current HTML conversion is

<a href="https://lifecycle.r-lib.org/articles/stages.html#deprecated">
  <img src="../help/figures/lifecycle-deprecated.svg" alt='[Deprecated]' />
</a>

If you have any suggestions on how this might be improved, please let me know. The more general problem of how to handle relative URLs will need more thought.

eliocamp commented 2 months ago

Maybe using this idiom might work in other browsers?

<object data=https://lifecycle.r-lib.org/articles/stages.html#deprecated" type="image/png"  alt='[Deprecated]'>
   <p>[Deprecated]</p>
</object>
hturner commented 2 months ago

It seems that {postdoc} uses Base64 encoding to convert such images to strings rather that using image URLs: https://github.com/ropensci/postdoc/blob/0ef879ffc5f1b878e11197b31198a3fb23ce2bc1/R/manual.R#L129. There jsonlite::base64_enc (https://github.com/ropensci/postdoc/blob/0ef879ffc5f1b878e11197b31198a3fb23ce2bc1/R/manual.R#L157) is used.

It seems possible but not efficient to implement base64 encoding in base R (https://coolbutuseless.github.io/2021/12/04/base64-encoding/decoding-in-plain-r/) but maybe this would be a useful functionality to have in base R (implemented in C) vs package space?