Skip to content

Commit 6f6b1a4

Browse files
committed
Improve the README.
1 parent ae8663a commit 6f6b1a4

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

README.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
[![Package](https://img.shields.io/crates/v/tldr-traits)](https://crates.io/crates/tldr-traits)
66
[![Documentation](https://docs.rs/tldr-traits/badge.svg)](https://docs.rs/tldr-traits)
77

8-
[Rust] abstractions for [TL;DR] summarization.
8+
[Rust] abstractions for [TL;DR] summarization using the [five Ws].
99

1010
## ✨ Features
1111

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.
1414
- Supports TL;DR generation for multiple natural languages.
1515
- Zero required dependencies, only optional integrations.
1616
- Adheres to the Rust API Guidelines in its [naming conventions].
@@ -46,23 +46,38 @@ tldr = { version = "0", package = "tldr-traits", default-features = false, featu
4646

4747
### Importing the Library
4848

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+
}
5166
```
5267

5368
## 📚 Reference
5469

5570
### [`ToTldr`]
5671

57-
```rust
72+
```rust,ignore
5873
pub trait ToTldr {
5974
fn to_tldr(&self) -> Box<dyn Tldr>;
6075
}
6176
```
6277

6378
### [`Tldr`]
6479

65-
```rust
80+
```rust,ignore
6681
pub trait Tldr {
6782
fn who(&self, ctx: &TldrContext) -> Option<String>;
6883
fn what(&self, ctx: &TldrContext) -> Option<String>;
@@ -112,9 +127,10 @@ git clone https://github.com/dryrust/tldr.rs.git
112127

113128
[Rust]: https://rust-lang.org
114129
[TL;DR]: https://en.wikipedia.org/wiki/TL;DR
130+
[five Ws]: https://en.wikipedia.org/wiki/Five_Ws
115131
[naming conventions]: https://rust-lang.github.io/api-guidelines/naming.html
116132

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

Comments
 (0)