-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Use tables to summarize course content #2005
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
Conversation
This is more friendly to translation (as it can share the translation of the title).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @djmitche!
mdbook-course/src/course.rs
Outdated
pub fn outline(&self, at_source_path: impl AsRef<Path>) -> String { | ||
let mut outline = String::from("In this segment:\n"); | ||
pub fn outline(&self) -> String { | ||
let mut slides = Table::new(["Slide".into(), "Time".into()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be slightly more accurate to call this a "duration"?
let mut slides = Table::new(["Slide".into(), "Time".into()]); | |
let mut slides = Table::new(["Slide".into(), "Duration".into()]); |
mdbook-course/src/course.rs
Outdated
outline | ||
format!( | ||
"Including {BREAK_DURATION} minute breaks, this session should take about {}. It contains:\n\n{}", | ||
duration(self.minutes()),segments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your rustfmt
has given up here 😄
duration(self.minutes()),segments) | |
duration(self.minutes()), segments) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it doesn't do much in macro invocations? I was surprised by this too.
mdbook-course/src/course.rs
Outdated
pub fn outline(&self, at_source_path: impl AsRef<Path>) -> String { | ||
let mut outline = String::from("In this session:\n"); | ||
pub fn outline(&self) -> String { | ||
let mut segments = Table::new(["Segment".into(), "Time".into()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps "duration" is better here?
let mut segments = Table::new(["Segment".into(), "Time".into()]); | |
let mut segments = Table::new(["Segment".into(), "Duration".into()]); |
mdbook-course/src/course.rs
Outdated
session.name, | ||
duration(session.minutes()) | ||
) | ||
.unwrap(); | ||
let mut segments = Table::new(["Segment".into(), "Time".into()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut segments = Table::new(["Segment".into(), "Time".into()]); | |
let mut segments = Table::new(["Segment".into(), "Duration".into()]); |
@@ -57,6 +58,46 @@ pub fn duration(mut minutes: u64) -> String { | |||
} | |||
} | |||
|
|||
/// Table implements Display to format a two-dimensional table as markdown, | |||
/// following https://github.github.com/gfm/#tables-extension-. | |||
pub struct Table<const N: usize> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! If you have time, it would be nice to have a small unit test below to show how the output looks like.
This is more friendly to translation (as it can share the translation of the title).
This fixes #1982.