Skip to contents

Builds the markdown for one chapter: the title as a level-one heading, an overview block, a questions block, then one heading per bullet.

Usage

draft_chapter(title, bullets, duration = 15, exercise = your_turn)

Arguments

title

Chapter title.

bullets

Character vector of bullet lines, indentation intact, as returned by parse_schedule().

duration

Minutes allotted to the chapter, shown in the overview.

exercise

A function returning the markdown lines for a section's exercise, or NULL to omit exercises entirely. Defaults to your_turn().

Value

A character vector of markdown lines.

Details

Exercises are attached to top-level (##) sections only. Sub-points sit beneath their parent section and share its exercise.

Examples

draft_chapter("Writing Functions", c("- Anatomy of a function", "- Good design"))
#>  [1] "# Writing Functions"                    
#>  [2] ""                                       
#>  [3] "## Overview"                            
#>  [4] ""                                       
#>  [5] "* **Duration** 15 minutes"              
#>  [6] ""                                       
#>  [7] "## Questions"                           
#>  [8] ""                                       
#>  [9] "## Anatomy of a function"               
#> [10] ""                                       
#> [11] "::: {.callout-note title=\"Your Turn\"}"
#> [12] ""                                       
#> [13] "1. TODO: exercise for this section."    
#> [14] ""                                       
#> [15] ":::"                                    
#> [16] ""                                       
#> [17] "## Good design"                         
#> [18] ""                                       
#> [19] "::: {.callout-note title=\"Your Turn\"}"
#> [20] ""                                       
#> [21] "1. TODO: exercise for this section."    
#> [22] ""                                       
#> [23] ":::"                                    
#> [24] ""                                       

# a chapter with no exercises
draft_chapter("Wrap Up", "- Q & A", exercise = NULL)
#>  [1] "# Wrap Up"                 ""                         
#>  [3] "## Overview"               ""                         
#>  [5] "* **Duration** 15 minutes" ""                         
#>  [7] "## Questions"              ""                         
#>  [9] "## Q & A"                  ""