|
5 | 5 | [](https://crates.io/crates/tldr-traits) |
6 | 6 | [](https://docs.rs/tldr-traits) |
7 | 7 |
|
8 | | -[Rust] abstractions for [TL;DR] summarization. |
| 8 | +[Rust] abstractions for [TL;DR] summarization using the [five Ws]. |
9 | 9 |
|
10 | 10 | ## ✨ Features |
11 | 11 |
|
12 | | -- Provides the trait [`Tldr`] to generate TL;DR summaries. |
13 | | -- Provides the trait [`ToTldr`] to convert objects into TL;DR summaries. |
| 12 | +- Provides the [`Tldr`] trait for generating TL;DR summaries. |
| 13 | +- Provides the [`ToTldr`] trait for converting objects into TL;DR summaries. |
14 | 14 | - Supports TL;DR generation for multiple natural languages. |
15 | 15 | - Zero required dependencies, only optional integrations. |
16 | 16 | - Adheres to the Rust API Guidelines in its [naming conventions]. |
@@ -46,23 +46,38 @@ tldr = { version = "0", package = "tldr-traits", default-features = false, featu |
46 | 46 |
|
47 | 47 | ### Importing the Library |
48 | 48 |
|
49 | | -```rust |
50 | | -use tldr::*; |
| 49 | +```rust,ignore |
| 50 | +use tldr::{Tldr, TldrContext, TldrSummary, ToTldr}; |
| 51 | +``` |
| 52 | + |
| 53 | +### Implementing the Trait |
| 54 | + |
| 55 | +```rust,ignore |
| 56 | +struct Rectangle { |
| 57 | + width: u32, |
| 58 | + height: u32, |
| 59 | +} |
| 60 | +
|
| 61 | +impl Tldr for Rectangle { |
| 62 | + fn what(&self, _ctx: &TldrContext) -> Option<String> { |
| 63 | + Some(format!("A rectangle with a width of {} and a height of {}.", self.width, self.height)) |
| 64 | + } |
| 65 | +} |
51 | 66 | ``` |
52 | 67 |
|
53 | 68 | ## 📚 Reference |
54 | 69 |
|
55 | 70 | ### [`ToTldr`] |
56 | 71 |
|
57 | | -```rust |
| 72 | +```rust,ignore |
58 | 73 | pub trait ToTldr { |
59 | 74 | fn to_tldr(&self) -> Box<dyn Tldr>; |
60 | 75 | } |
61 | 76 | ``` |
62 | 77 |
|
63 | 78 | ### [`Tldr`] |
64 | 79 |
|
65 | | -```rust |
| 80 | +```rust,ignore |
66 | 81 | pub trait Tldr { |
67 | 82 | fn who(&self, ctx: &TldrContext) -> Option<String>; |
68 | 83 | fn what(&self, ctx: &TldrContext) -> Option<String>; |
@@ -112,9 +127,10 @@ git clone https://github.com/dryrust/tldr.rs.git |
112 | 127 |
|
113 | 128 | [Rust]: https://rust-lang.org |
114 | 129 | [TL;DR]: https://en.wikipedia.org/wiki/TL;DR |
| 130 | +[five Ws]: https://en.wikipedia.org/wiki/Five_Ws |
115 | 131 | [naming conventions]: https://rust-lang.github.io/api-guidelines/naming.html |
116 | 132 |
|
117 | | -[`Tldr`]: # |
118 | | -[`TldrContext`]: # |
119 | | -[`TldrSummary`]: # |
120 | | -[`ToTldr`]: # |
| 133 | +[`Tldr`]: https://docs.rs/tldr-traits/latest/tldr_traits/trait.Tldr.html |
| 134 | +[`TldrContext`]: https://docs.rs/tldr-traits/latest/tldr_traits/struct.TldrContext.html |
| 135 | +[`TldrSummary`]: https://docs.rs/tldr-traits/latest/tldr_traits/struct.TldrSummary.html |
| 136 | +[`ToTldr`]: https://docs.rs/tldr-traits/latest/tldr_traits/trait.ToTldr.html |
0 commit comments