Skip to content

Commit 1134258

Browse files
committed
Documentation improvements
1 parent 0d00185 commit 1134258

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ While using an immediate mode gui is simple, implementing one is a lot more tric
6262
* read some code before writing your own
6363
* follow the `egui` code style
6464
* add blank lines around all `fn`, `struct`, `enum`, etc.
65+
* `// Comment like this`, not `//like this`
6566
* write idiomatic rust
6667
* avoid `unsafe`
6768
* avoid code that can cause panics

egui/src/widgets/text_edit/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::{CCursorRange, CursorRange, TextEditOutput, TextEditState};
88

99
/// A text region that the user can edit the contents of.
1010
///
11-
/// See also [`Ui::text_edit_singleline`] and [`Ui::text_edit_multiline`].
11+
/// See also [`Ui::text_edit_singleline`] and [`Ui::text_edit_multiline`].
1212
///
1313
/// Example:
1414
///

egui_demo_lib/src/easy_mark/easy_mark_highlighter.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,22 @@ pub fn highlight_easymark(egui_style: &egui::Style, mut text: &str) -> egui::tex
6161
if text.starts_with('\\') && text.len() >= 2 {
6262
skip = 2;
6363
} else if start_of_line && text.starts_with(' ') {
64-
// indentation we don't preview indentation, because it is confusing
64+
// we don't preview indentation, because it is confusing
6565
skip = 1;
6666
} else if start_of_line && text.starts_with("# ") {
6767
style.heading = true;
6868
skip = 2;
6969
} else if start_of_line && text.starts_with("> ") {
7070
style.quoted = true;
7171
skip = 2;
72-
// indentation we don't preview indentation, because it is confusing
72+
// we don't preview indentation, because it is confusing
7373
} else if start_of_line && text.starts_with("- ") {
7474
skip = 2;
75-
// indentation we don't preview indentation, because it is confusing
75+
// we don't preview indentation, because it is confusing
7676
} else if text.starts_with('*') {
7777
skip = 1;
7878
if style.strong {
79-
// Include the character that i ending ths style:
79+
// Include the character that is ending this style:
8080
job.append(&text[..skip], 0.0, format_from_style(egui_style, &style));
8181
text = &text[skip..];
8282
skip = 0;
@@ -85,7 +85,7 @@ pub fn highlight_easymark(egui_style: &egui::Style, mut text: &str) -> egui::tex
8585
} else if text.starts_with('$') {
8686
skip = 1;
8787
if style.small {
88-
// Include the character that i ending ths style:
88+
// Include the character that is ending this style:
8989
job.append(&text[..skip], 0.0, format_from_style(egui_style, &style));
9090
text = &text[skip..];
9191
skip = 0;
@@ -94,7 +94,7 @@ pub fn highlight_easymark(egui_style: &egui::Style, mut text: &str) -> egui::tex
9494
} else if text.starts_with('^') {
9595
skip = 1;
9696
if style.raised {
97-
// Include the character that i ending ths style:
97+
// Include the character that is ending this style:
9898
job.append(&text[..skip], 0.0, format_from_style(egui_style, &style));
9999
text = &text[skip..];
100100
skip = 0;

egui_demo_lib/src/easy_mark/easy_mark_parser.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
//! A parser for `EasyMark`: a very simple markup language.
22
//!
33
//! WARNING: `EasyMark` is subject to change.
4-
//!
5-
//! This module does not depend on anything else in egui
6-
//! and should perhaps be its own crate.
74
//
85
//! # `EasyMark` design goals:
96
//! 1. easy to parse

emath/src/rect.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,29 @@ use crate::*;
55

66
/// A rectangular region of space.
77
///
8-
/// Normally given in points, e.g. logical pixels.
8+
/// Usually a `Rect` has a positive (or zero) size,
9+
/// and then [`Self::min`] `<=` [`Self::max`].
10+
/// In these cases [`Self::min`] is the left-top corner
11+
/// and [`Self::max`] is the right-bottom corner.
12+
///
13+
/// A rectangle is allowed to have a negative size, which happens when the order
14+
/// of `min` and `max` are swapped. These are usually a sign of an error.
15+
///
16+
/// Normally the unit is points (logical pixels) in screen space coordinates.
917
#[repr(C)]
1018
#[derive(Clone, Copy, Eq, PartialEq)]
1119
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
1220
#[cfg_attr(feature = "bytemuck", derive(bytemuck::Pod, bytemuck::Zeroable))]
1321
pub struct Rect {
22+
/// One of the corners of the rectangle, usually the left top one.
1423
pub min: Pos2,
24+
25+
/// The other corner, opposing [`Self::min`]. Usually the right bottom one.
1526
pub max: Pos2,
1627
}
1728

1829
impl Rect {
19-
/// Infinite rectangle that contains everything.
30+
/// Infinite rectangle that contains every point.
2031
pub const EVERYTHING: Self = Self {
2132
min: pos2(-INFINITY, -INFINITY),
2233
max: pos2(INFINITY, INFINITY),
@@ -25,19 +36,14 @@ impl Rect {
2536
/// The inverse of [`Self::EVERYTHING`]: stretches from positive infinity to negative infinity.
2637
/// Contains no points.
2738
///
28-
/// This is useful as the seed for bounding bounding boxes.
29-
///
30-
/// ```
31-
/// # use emath::*;
32-
/// let inf = f32::INFINITY;
33-
/// assert!(Rect::NOTHING.size() == Vec2::splat(-inf));
34-
/// assert!(Rect::NOTHING.contains(pos2(0.0, 0.0)) == false);
35-
/// ```
39+
/// This is useful as the seed for bounding boxes.
3640
///
3741
/// # Example:
3842
/// ```
3943
/// # use emath::*;
4044
/// let mut rect = Rect::NOTHING;
45+
/// assert!(rect.size() == Vec2::splat(-f32::INFINITY));
46+
/// assert!(rect.contains(pos2(0.0, 0.0)) == false);
4147
/// rect.extend_with(pos2(2.0, 1.0));
4248
/// rect.extend_with(pos2(0.0, 3.0));
4349
/// assert_eq!(rect, Rect::from_min_max(pos2(0.0, 1.0), pos2(2.0, 3.0)))
@@ -50,14 +56,15 @@ impl Rect {
5056
/// An invalid `Rect` filled with [`f32::NAN`];
5157
pub const NAN: Self = Self {
5258
min: pos2(f32::NAN, f32::NAN),
53-
max: pos2(-f32::NAN, -f32::NAN),
59+
max: pos2(f32::NAN, f32::NAN),
5460
};
5561

5662
#[inline(always)]
5763
pub const fn from_min_max(min: Pos2, max: Pos2) -> Self {
5864
Rect { min, max }
5965
}
6066

67+
/// left-top corner plus a size (stretching right-down).
6168
#[inline(always)]
6269
pub fn from_min_size(min: Pos2, size: Vec2) -> Self {
6370
Rect {
@@ -82,6 +89,7 @@ impl Rect {
8289
}
8390
}
8491

92+
/// Returns the bounding rectangle of the two points.
8593
#[inline]
8694
pub fn from_two_pos(a: Pos2, b: Pos2) -> Self {
8795
Rect {
@@ -90,7 +98,7 @@ impl Rect {
9098
}
9199
}
92100

93-
/// Bounding-box around the points
101+
/// Bounding-box around the points.
94102
pub fn from_points(points: &[Pos2]) -> Self {
95103
let mut rect = Rect::NOTHING;
96104
for &p in points {

0 commit comments

Comments
 (0)