-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Use shinylive to show the app on the README #1490
base: main
Are you sure you want to change the base?
Conversation
Unit Tests Summary 1 files 27 suites 10m 22s ⏱️ Results for commit 7950690. ♻️ This comment has been updated with latest results. |
Unit Test Performance Difference
Additional test case details
Results for commit 11387bd ♻️ This comment has been updated with latest results. |
Code Coverage Summary
Diff against main
Results for commit: 7950690 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
…htsengineering/teal into 1404_shinylive_readme@main
From
If we want to include the app we'll need a different README for the repo/github view and another for github pages. This would require tweaking the action on insightsengineering/r.pkg.template/.github/workflows/pkgdown.yaml@main to pick the right README.md as it currently pulls the repository from a branch (or that a commit is made directly to that branch). This becomes quite complicated and wouldn't be ready for the release tomorrow. Adding a link it is fairly simple and portable: I'll keep the video recorded and just the link to where users can visualize the output. |
Our .pre-commit-confit.yaml is based on https://github.com/lorenzwalthert/precommit which has this hook already included: You just need to extend - id: readme-rmd-rendered
name: Render README.md |
I don't understand this. The docs action has a step that renders README.Rmd to Readme.md right? This Readme.md is committed to the rspository. And then pkgdown, in the next step, takes the freshly knitted Readme.md. So why we want two README? |
Yes, the README.Rmd is rended to README.md and committed to the repository. I've added the job on the docs.yaml to render the README file, but this is only to ensure the file is up to date. The README.Rmd must be rendered to a README.md so that pkgdown can use it.
If we want to include we would need to render it into different format but not sure how it would play with the CI and the pkgdown internal machinery. |
Yeah, so the action can render into index.html and into README.md and I think it should be fine. Action can also remove any unnecessary chunk options that will be problematic or unused in README.md by GitHub when showing the welcome page on the repository. I would suggest rendering README.Rmd into 2 files: index.html and README.md |
Let me raise a small PR to just add the shinylive in the Getting started vignette. Readme can wait, but I think the getting started vignette can go in before the release. |
Can any one of you just review this PR #1491? |
cat(sprintf("[Open in Shinylive](%s)\n\n", url)) | ||
``` | ||
|
||
```{r shinylive_iframe, echo = FALSE, out.width = '150%', out.extra = 'style = "position: relative; z-index:1"', eval = requireNamespace("roxy.shinylive", quietly = TRUE) && knitr::is_html_output() && identical(Sys.getenv("IN_PKGDOWN"), "true")} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition probably needs some rework
this is very specific to the vigniette that we want to have only in pkgdown website but not in the help panel. I don't think this holds true here.
For instance, I think it's reasonable to expect this to be rendered in the GitHub preview here: https://github.com/insightsengineering/teal/tree/1404_shinylive_readme%40main?tab=readme-ov-file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I'm not sure we can insert iframes on markdown format with knitr. See the error message when I simplified the condition: #1490 (comment). Some sites say iframes are supported while other says it is disabled due to security concerns. But this might be a knitr limitation as I saw some comments about using some flags on pandoc to insert iframes.
In addition, if we want the iframe to show on the pkgdown index.html we need to render it to markdown ourselves as pkgdown won't do it (see this previous comment). But it might take time to do this on the GHA and won't be ready for today's release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok thanks for the reply. I agree - let's not block the release because of that and let's investigate this afterwards
The shinylive is not included on the pkgdown file. Test code: # Build the README.md for repository
devtools::build_readme()
# Build the index.md for pkgdown
Sys.setenv(IN_PKGDOWN = "true")
devtools::build_readme(output_format = "html_document", output_file = "index.html")
knitr::knit("index.html", output = "index.md")
# Check website
unlink("index.html") # Delete just in case it is not overwritten
pkgdown::build_home() # Build index.html file from the index.md file If we follow this instructions we will see that index.md has the iframe code I think adding a link to the README and pkgdown home page is the best we can do for now. In addition, the index.md is a 2.7Mb file that is very slow to open (it crashed my computer), not sure if GitHub pages will render that directly (see also previous comments suggesting it is not possible to render iframes). |
Yeah indeed - looks like iframe is not supported as per official docs. I have one more idea but a little bit more difficult: a separate |
@pawelru The script above generates an index.md with an iframe. But pkgdown doesn't include the iframe when built locally (see the screenshot). I don't think building the website differently would fix that, I don't see any parameter that could help. There are some issues regarding iframes on pkgdown issue tracker, but nothing about shinylive (yet?). In general it is mentioned as a workaround around an issue. |
Pull Request
Fixes #1404
Converted the README.md to README.Rmd to be able to genereate a shinylive of the example app.
The space modifications are automatically but I just made very few modifications to the file: add some code chunk options and two chunks at the end.
It adds some steps on the docs.yaml to render the README (iff modified).
Note: I haven't removed the preview yet (I want to see how it works and then I'll remove it).
There is a comment about having a git hook locally.
usethis::use_readme_rmd()
generates a hook to be added to.git/hooks/pre-commit
(not sure if this could be shared via .pre-commit-config.yaml).Hook