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 knit task #608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add knit task #608

wants to merge 1 commit into from

Conversation

krlmlr
Copy link
Contributor

@krlmlr krlmlr commented Apr 6, 2021

Expand list of tasks so that documents kan be rendered in a fresh session using tasks. Reference: #59 (comment).

Open an .Rmd file, run the "R: Knit" task.

I wonder:

  • How can we expand the task so that the rendered document is opened upon completion? Should we add an rstudioapi::xxx() call to the command line?
  • Do we need "Knit as HTML", "Knit as PDF", "Knit all"?
  • Should we eventually remap the Ctrl + Shift + K shortcut to this task
    • and enable it also for .R files
    • and also remap other shortcuts?

@malcook
Copy link

malcook commented Apr 6, 2021

thought as an often emacs org-mode ESS (emacs speaks statistics) user and sometime rstudio user who would love to jump to VSC when possible:

"Knit to xxx" is good

"Knit All" is good and should knit to all formats in YAML header, of html if none.

Ctrl + Shift + K is what RStudio uses and is good unless otherwise claimed.

The YAML header of an rmarkdown document can specify one of more formats to which the document is expected to be knit, but a call to knit can override.

@jooyoungseo
Copy link
Contributor

In RStudio IDE, the knit button (ctrl+shift+K) behaves differently depending on how you define knit  field within the YAML frontmatter of your document.

This has been described in Customize the Knit button.

For example, the following calls bookdown::render_book() instead of the default rmarkdown::render():

index.Rmd:

---
title: Bookdown Rmd
knit: "bookdown::render_book"
output: bookdown::gitbook
---

It would be ideal if the knit task could pick up the knit metadata field within current document yaml frontmatter, and use the defined render function towards the opened file as in RStudio IDE.

@andycraig
Copy link
Collaborator

@krlmlr Thanks for this PR! I'm happy to review it whenever you'd like. Adding knit HTML/PDF/all variations might be worthwhile now as they should be straightforward. You're welcome to take on other features like automatically opening the knitted document but it seems like it might be easiest to merge the basic features now and add on the more involved features in subsequent PRs.

@gowerc
Copy link
Contributor

gowerc commented Feb 16, 2022

@krlmlr,

Can I just double check what you were trying to achieve here. The current Ctrl + Shift + K shortcut already runs the Rmd in a fresh R session. I'm just wondering what the benefit of mapping it over to tasks instead would be.

To @jooyoungseo's point it also looks like the existing knit all / Ctrl + Shift + K also respects the knit frontmatter

image

Theres also quite a bit of chat here around different potential features we could implement is it worth extracting these to separate issues ? I would propose closing this PR considering its now outdated/incompatible with the current changes to tasks.ts. I started putting together a new version that is compatible with the new changes but am unsure now of its value given what I've put above. @renkun-ken any opinions ?

@jooyoungseo
Copy link
Contributor

@gowerc I believe the customizable knit (at least my suggestion) has already been addressed in the latest version, so this is somewhat outdated.

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

Successfully merging this pull request may close these issues.

5 participants