Skip to content

Commit 79b401f

Browse files
authored
docs: added docs for all missing public API
docs: added docs for all missing public API
2 parents f6379dd + 7d1af51 commit 79b401f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,20 @@ pub enum CharacterRule {
150150
}
151151

152152
impl Default for CharacterRule {
153+
/// Returns `Self::Always(' ')`
153154
fn default() -> Self {
154155
Self::Always(' ')
155156
}
156157
}
157158

159+
/// Determines how to style a Cell.
160+
/// [`StyleRule::ColorFg`] only applies the color from the shader to the foreground of the Cell.
161+
/// [`StyleRule::ColorBg`] only applies the color from the shader to the background of the Cell. This
162+
/// is the default value.
163+
/// [`StyleRule::ColorFgAndBg`] applies the color from the shader to the foreground and background of the Cell.
164+
/// [`StyleRule::Map`] takes a function as an argument and allows you to map the input [`Sample`] to
165+
/// a Style. For example, one might use the transparency value from the shader ([Sample::a]) and set
166+
/// a cutoff for switching between bold and non-bold text.
158167
#[derive(Debug, Default, Clone, Eq, PartialEq)]
159168
pub enum StyleRule {
160169
ColorFg,
@@ -164,6 +173,8 @@ pub enum StyleRule {
164173
Map(fn(Sample) -> Style),
165174
}
166175

176+
/// Primarily used in [`CharacterRule::Map`] and [`StyleRule::Map`], it provides access to a Cells color and position
177+
/// allowing to map the output of the shader to more complex behaviour.
167178
pub struct Sample {
168179
value: [u8; 4],
169180
position: (u16, u16),
@@ -174,26 +185,32 @@ impl Sample {
174185
Self { value, position }
175186
}
176187

188+
/// The red channel of the [`Sample`]
177189
pub fn r(&self) -> u8 {
178190
self.value[0]
179191
}
180192

193+
/// The green channel of the [`Sample`]
181194
pub fn g(&self) -> u8 {
182195
self.value[1]
183196
}
184197

198+
/// The blue channel of the [`Sample`]
185199
pub fn b(&self) -> u8 {
186200
self.value[2]
187201
}
188202

203+
/// The alpha channel of the [`Sample`]
189204
pub fn a(&self) -> u8 {
190205
self.value[3]
191206
}
192207

208+
/// The x coordinate of the [`Sample`]
193209
pub fn x(&self) -> u16 {
194210
self.position.0
195211
}
196212

213+
/// The y coordinate of the [`Sample`]
197214
pub fn y(&self) -> u16 {
198215
self.position.1
199216
}

0 commit comments

Comments
 (0)