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

Render a document from a script (.R, .py) #6660

Closed
cderv opened this issue Aug 30, 2023 · 4 comments · Fixed by #7696
Closed

Render a document from a script (.R, .py) #6660

cderv opened this issue Aug 30, 2023 · 4 comments · Fixed by #7696
Labels
enhancement New feature or request
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Aug 30, 2023

This idea cames from several discussion - especially on the R side as we have knitr::spin() and rmarkdown::render() working with R script

quarto render could consider rendering to output format a .R / .py script that represents a notebook.

Notes

These are from internal discussion on this already

General

  • This kind of feature would be opt-in to avoid rendering a script that shouldn't be. Probably by using a specific comment in the script that quarto could check
    • Example for .py : # %% [markdown] if we see this, then we auto render

      # %% [markdown]
      # ---
      # title: "My document"
      # ---
      
    • Other idea: Requiring a title field in YAML header

      • For R
        #' ---
        #' title: "My document"
        #' ---
        
      • For Python
        # %% [markdown]
        # ---
        # title: "My document"
        # ---
        

For Python

This issue is to track the idea and have a place for further notes.

@cderv cderv added the enhancement New feature or request label Aug 30, 2023
@cderv cderv added this to the Future milestone Aug 30, 2023
@kylebutts
Copy link

In this line, VSCode has support for plain .py files with the # %% code format:

CleanShot 2023-08-30 at 10 21 07@2x

This lets you work with plain text files but have the ability to view output like a notebook. If this is your development flow (like it is mine), being able to "log" the script afterwards would be delightful!

@cderv
Copy link
Collaborator Author

cderv commented Sep 4, 2023

First work for Python

@cderv
Copy link
Collaborator Author

cderv commented Sep 5, 2023

1.4 prerelease support for rendering script using Jupyter engine
https://quarto.org/docs/prerelease/1.4/script.html

knitr engine support with spin() syntax coming soon

@kylebutts
Copy link

kylebutts commented Nov 26, 2023

Getting this to work (minimally) should work for an .R script with yihui/knitr#2307

For markdown, currently you use roxygen style comments #'. Adding the option for # %% [markdown] and # %% [raw] should be possible with R raw strings with a some work on the knitr::spin function

# %% [markdown] 
r'(
# Header

Body text
)'

@mcanouil mcanouil modified the milestones: Future, v1.4 Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants