1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-02 06:32:19 +02:00

Do not include timing info in sub-chapters of slides (#1538)

Timing information is for a slide as a whole, so we use a sentence like
"This slide and its sub-slides should take about 15 minutes" in the
first chapter in the slide. Subsequent chapters in the same slide do not
need timing information.

Fixes #1552.
This commit is contained in:
Dustin J. Mitchell 2023-12-04 09:56:44 -05:00 committed by GitHub
parent 11a8334aa4
commit 1fa6b7438b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -447,6 +447,13 @@ impl Slide {
Ok(())
}
/// Determine whether the given chapter is a sub-chapter of this slide.
pub fn is_sub_chapter(&self, chapter: &Chapter) -> bool {
// The first `source_path` in the slide is the "parent" chapter, so anything
// else is a sub-chapter.
chapter.source_path.as_ref() != self.source_paths.get(0)
}
/// Return the total duration of this slide.
pub fn minutes(&self) -> u64 {
self.minutes

View File

@ -17,7 +17,10 @@ use mdbook::book::Chapter;
/// Insert timing information for this slide into the speaker notes.
pub fn insert_timing_info(slide: &Slide, chapter: &mut Chapter) {
if slide.minutes > 0 && chapter.content.contains("<details>") {
if slide.minutes > 0
&& !slide.is_sub_chapter(chapter)
&& chapter.content.contains("<details>")
{
// Include the minutes in the speaker notes.
let minutes = slide.minutes;
let plural = if slide.minutes == 1 {