From 9f67c9b0e78926170b948719678294e4efd5350f Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Tue, 6 Feb 2024 15:48:56 -0500 Subject: [PATCH] Adjust morning-session timings downward (#1786) Based on feedback from @marshallpierce that mornings took about 2.5 hours, this adjusts a bunch of the morning times downward to try to match that. In other words, this is trying to make the times in the course more accurate, rather than reducing the amount of time available for these slides. This also updates the `course-schedule` tool to be able to show per-segment timings. --- mdbook-course/src/bin/course-schedule.rs | 66 +++++++++++++++----- src/control-flow-basics/blocks-and-scopes.md | 2 +- src/control-flow-basics/break-continue.md | 2 +- src/control-flow-basics/conditionals.md | 2 +- src/generics/generic-data.md | 2 +- src/generics/trait-bounds.md | 2 +- src/iterators/iterator.md | 4 -- src/memory-management/copy-types.md | 4 -- src/memory-management/drop.md | 2 +- src/memory-management/move.md | 2 +- src/methods-and-traits/deriving.md | 2 +- src/methods-and-traits/methods.md | 2 +- src/methods-and-traits/traits.md | 2 +- src/modules/modules.md | 2 +- src/modules/paths.md | 2 +- src/pattern-matching/destructuring.md | 2 +- src/smart-pointers/box.md | 2 +- src/testing/lints.md | 2 +- src/testing/other.md | 2 +- src/testing/unit-tests.md | 2 +- src/types-and-values/arithmetic.md | 2 +- src/types-and-values/inference.md | 2 +- src/types-and-values/strings.md | 2 +- src/types-and-values/values.md | 2 +- 24 files changed, 70 insertions(+), 46 deletions(-) diff --git a/mdbook-course/src/bin/course-schedule.rs b/mdbook-course/src/bin/course-schedule.rs index a076c5023f32..b11c5a180a5c 100644 --- a/mdbook-course/src/bin/course-schedule.rs +++ b/mdbook-course/src/bin/course-schedule.rs @@ -12,21 +12,29 @@ // See the License for the specific language governing permissions and // limitations under the License. +use clap::Command; use mdbook::MDBook; -use mdbook_course::course::{Course, Courses}; +use mdbook_course::course::Courses; use mdbook_course::markdown::duration; fn main() { pretty_env_logger::init(); + let app = Command::new("mdbook-course") + .about("mdbook preprocessor for Comprehensive Rust") + .subcommand(Command::new("sessions").about("Show session summary (default)")) + .subcommand(Command::new("segments").about("Show segment summary")) + .subcommand(Command::new("pr").about("Show summary for a PR")); + let matches = app.get_matches(); + let root_dir = "."; let mdbook = MDBook::load(root_dir).expect("Unable to load the book"); let (courses, _) = Courses::extract_structure(mdbook.book) .expect("Unable to extract course structure"); - println!("## Course Schedule"); - println!("With this pull request applied, the course schedule is as follows:"); - for course in &courses { - print_summary(course); + match matches.subcommand() { + Some(("session", _)) | None => session_summary(&courses), + Some(("pr", _)) => pr_summary(&courses), + _ => unreachable!(), } } @@ -44,18 +52,42 @@ fn timediff(actual: u64, target: u64, slop: u64) -> String { } } -fn print_summary(course: &Course) { - if course.target_minutes() == 0 { - return; +fn session_summary(courses: &Courses) { + for course in courses { + if course.target_minutes() == 0 { + return; + } + for session in course { + println!("### {} // {}", course.name, session.name); + println!( + "_{}_", + timediff(session.minutes(), session.target_minutes(), 15) + ); + println!(); + for segment in session { + println!("* {} - _{}_", segment.name, duration(segment.minutes())); + } + println!(); + } } - println!("### {}", course.name); - println!("_{}_", timediff(course.minutes(), course.target_minutes(), 15)); - - for session in course { - println!( - "* {} - _{}_", - session.name, - timediff(session.minutes(), session.target_minutes(), 5) - ); +} + +fn pr_summary(courses: &Courses) { + println!("## Course Schedule"); + println!("With this pull request applied, the course schedule is as follows:"); + for course in courses { + if course.target_minutes() == 0 { + return; + } + println!("### {}", course.name); + println!("_{}_", timediff(course.minutes(), course.target_minutes(), 15)); + + for session in course { + println!( + "* {} - _{}_", + session.name, + timediff(session.minutes(), session.target_minutes(), 5) + ); + } } } diff --git a/src/control-flow-basics/blocks-and-scopes.md b/src/control-flow-basics/blocks-and-scopes.md index 3e8d685e0fbe..76a1da0c999e 100644 --- a/src/control-flow-basics/blocks-and-scopes.md +++ b/src/control-flow-basics/blocks-and-scopes.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 5 --- # Blocks and Scopes diff --git a/src/control-flow-basics/break-continue.md b/src/control-flow-basics/break-continue.md index 6cad37fdbb1f..e46a3382941f 100644 --- a/src/control-flow-basics/break-continue.md +++ b/src/control-flow-basics/break-continue.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 4 --- # `break` and `continue` diff --git a/src/control-flow-basics/conditionals.md b/src/control-flow-basics/conditionals.md index 03bd50e43696..81378ac3332f 100644 --- a/src/control-flow-basics/conditionals.md +++ b/src/control-flow-basics/conditionals.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 4 --- # Conditionals diff --git a/src/generics/generic-data.md b/src/generics/generic-data.md index 54bc15b2e1cf..8724524970ec 100644 --- a/src/generics/generic-data.md +++ b/src/generics/generic-data.md @@ -1,5 +1,5 @@ --- -minutes: 15 +minutes: 10 --- # Generic Data Types diff --git a/src/generics/trait-bounds.md b/src/generics/trait-bounds.md index 2ebdcb62d33e..75581414e2ce 100644 --- a/src/generics/trait-bounds.md +++ b/src/generics/trait-bounds.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # Trait Bounds diff --git a/src/iterators/iterator.md b/src/iterators/iterator.md index 826e1ac0451e..d0b7c0726914 100644 --- a/src/iterators/iterator.md +++ b/src/iterators/iterator.md @@ -2,10 +2,6 @@ minutes: 5 --- - - # `Iterator` The [`Iterator`][1] trait supports iterating over values in a collection. It diff --git a/src/memory-management/copy-types.md b/src/memory-management/copy-types.md index 835222b94320..25f5cfb525a4 100644 --- a/src/memory-management/copy-types.md +++ b/src/memory-management/copy-types.md @@ -2,10 +2,6 @@ minutes: 5 --- - - # Copy Types While move semantics are the default, certain types are copied by default: diff --git a/src/memory-management/drop.md b/src/memory-management/drop.md index 698a06754bfe..4f7a9f3df760 100644 --- a/src/memory-management/drop.md +++ b/src/memory-management/drop.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # The `Drop` Trait diff --git a/src/memory-management/move.md b/src/memory-management/move.md index aacfaa34d218..53c982991a0f 100644 --- a/src/memory-management/move.md +++ b/src/memory-management/move.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 5 --- # Move Semantics diff --git a/src/methods-and-traits/deriving.md b/src/methods-and-traits/deriving.md index ac4efe9e9d29..99190a03339a 100644 --- a/src/methods-and-traits/deriving.md +++ b/src/methods-and-traits/deriving.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 3 --- # Deriving diff --git a/src/methods-and-traits/methods.md b/src/methods-and-traits/methods.md index 06269721597a..f16268a3387a 100644 --- a/src/methods-and-traits/methods.md +++ b/src/methods-and-traits/methods.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # Methods diff --git a/src/methods-and-traits/traits.md b/src/methods-and-traits/traits.md index ce483b3f6c26..1a5924d983f3 100644 --- a/src/methods-and-traits/traits.md +++ b/src/methods-and-traits/traits.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # Traits diff --git a/src/modules/modules.md b/src/modules/modules.md index d06308855365..5c6b7f53ed80 100644 --- a/src/modules/modules.md +++ b/src/modules/modules.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 3 --- # Modules diff --git a/src/modules/paths.md b/src/modules/paths.md index f8f570adebfb..9497b5b5f65d 100644 --- a/src/modules/paths.md +++ b/src/modules/paths.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # use, super, self diff --git a/src/pattern-matching/destructuring.md b/src/pattern-matching/destructuring.md index 6df5ea5418da..228959ff9814 100644 --- a/src/pattern-matching/destructuring.md +++ b/src/pattern-matching/destructuring.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # Destructuring diff --git a/src/smart-pointers/box.md b/src/smart-pointers/box.md index a8e66c426d2f..7074f8f7d54c 100644 --- a/src/smart-pointers/box.md +++ b/src/smart-pointers/box.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 8 --- # `Box` diff --git a/src/testing/lints.md b/src/testing/lints.md index 846ecf7fc456..2df1a79abc7a 100644 --- a/src/testing/lints.md +++ b/src/testing/lints.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 3 --- # Compiler Lints and Clippy diff --git a/src/testing/other.md b/src/testing/other.md index f1eea8e18617..b361829b33d9 100644 --- a/src/testing/other.md +++ b/src/testing/other.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 5 --- # Other Types of Tests diff --git a/src/testing/unit-tests.md b/src/testing/unit-tests.md index fc99bf67c0c1..2c3495f5ffee 100644 --- a/src/testing/unit-tests.md +++ b/src/testing/unit-tests.md @@ -23,7 +23,7 @@ fn first_word(text: &str) -> &str { } #[cfg(test)] -mod test { +mod tests { use super::*; #[test] diff --git a/src/types-and-values/arithmetic.md b/src/types-and-values/arithmetic.md index 30ebbc5920e8..8e7eb072995b 100644 --- a/src/types-and-values/arithmetic.md +++ b/src/types-and-values/arithmetic.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 3 --- # Arithmetic diff --git a/src/types-and-values/inference.md b/src/types-and-values/inference.md index 8a82a48e5be5..1da78bf1bd54 100644 --- a/src/types-and-values/inference.md +++ b/src/types-and-values/inference.md @@ -1,5 +1,5 @@ --- -minutes: 5 +minutes: 3 --- # Type Inference diff --git a/src/types-and-values/strings.md b/src/types-and-values/strings.md index 1d52e2eab556..47b0d13aca18 100644 --- a/src/types-and-values/strings.md +++ b/src/types-and-values/strings.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 5 --- # Strings diff --git a/src/types-and-values/values.md b/src/types-and-values/values.md index 311a27e1da6b..71bef8e62c85 100644 --- a/src/types-and-values/values.md +++ b/src/types-and-values/values.md @@ -1,5 +1,5 @@ --- -minutes: 10 +minutes: 5 --- # Values