quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.77k stars 308 forks source link

[Question/Feature Request] Parameterised notebooks within projects #864

Open p-gw opened 2 years ago

p-gw commented 2 years ago

Hi everyone,

I have a question regarding a somewhat advanced use case: If I have created a project that contains a simple notebook (e.g. introduction.qmd) and a parameterised notebook (e.g. report_by_state.qmd) whose output is required multiple times with different parameter values is it possible to render the whole project using quarto render?

Say I want to render introduction.qmd and report_by_state.qmd for state 1, 2, and 3. If using html outputs this should result in

It is of course possible to write a shell script to render reports in this way, but I think it would be nice if there was something like this

project:
    render:
        - introduction.qmd
        - input: report_by_state.qmd
          params: 
              state: 1
          output: report_state_1.html
        - input: report_by_state.qmd
          params: 
              state: 2
          output: report_state_2.html
        - input: report_by_state.qmd
          params: 
              state: 3
          output: report_state_3.html

and being able to render everything with a single quarto render.

Except writing a custom shell script, is there currently a method which makes it possible to achieve something like this?

jjallaire commented 2 years ago

We don't currently have anything like that (but its a great idea!). We'll definitely consider this for a future release

p-gw commented 2 years ago

Thanks for the reply, I'm looking forward to seeing this implemented.

In case anybody stumbles upon this issue, here is my current workaround using a simple shell script like I mentioned above:

#!/bin/bash
for state in 1 2 3
do
  quarto render _report_by_state.qmd --output report_state_$state.html -P state:$state
done

quarto render

Some things to note:

petrbouchal commented 1 year ago

A related challenge is to have the generated reports listed either in a listing or in a sidebar - currently (AFAICT)