Some minor corrections from code review.

This commit is contained in:
Eric Huss 2023-09-02 16:41:59 -07:00
parent 8564a7fb51
commit 4749f9d97a
2 changed files with 5 additions and 5 deletions

View file

@ -48,7 +48,7 @@ This is general information about your book.
- **language:** The main language of the book, which is used as a language attribute `<html lang="en">` for example. - **language:** The main language of the book, which is used as a language attribute `<html lang="en">` for example.
This is also used to derive the direction of text (RTL, LTR) within the book. This is also used to derive the direction of text (RTL, LTR) within the book.
- **text_direction**: The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). Possible values: `ltr`, `rtl`. - **text_direction**: The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). Possible values: `ltr`, `rtl`.
When not specified, the correct text direction is derived from the book's `language` attribute. When not specified, the text direction is derived from the book's `language` attribute.
**book.toml** **book.toml**
```toml ```toml

View file

@ -412,7 +412,7 @@ pub struct BookConfig {
/// The main language of the book. /// The main language of the book.
pub language: Option<String>, pub language: Option<String>,
/// The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL). /// The direction of text in the book: Left-to-right (LTR) or Right-to-left (RTL).
/// When not specified, the correct text direction is derived from [BookConfig::language]. /// When not specified, the text direction is derived from [`BookConfig::language`].
pub text_direction: Option<TextDirection>, pub text_direction: Option<TextDirection>,
} }
@ -431,13 +431,13 @@ impl Default for BookConfig {
} }
impl BookConfig { impl BookConfig {
/// Gets the realized text direction, either from [BookConfig::text_direction] /// Gets the realized text direction, either from [`BookConfig::text_direction`]
/// or derived from [BookConfig::language], to be used by templating engines. /// or derived from [`BookConfig::language`], to be used by templating engines.
pub fn realized_text_direction(&self) -> TextDirection { pub fn realized_text_direction(&self) -> TextDirection {
if let Some(direction) = self.text_direction { if let Some(direction) = self.text_direction {
direction direction
} else { } else {
TextDirection::from_lang_code(&self.language.clone().unwrap_or_default()) TextDirection::from_lang_code(self.language.as_deref().unwrap_or_default())
} }
} }
} }