Skip to content

Commit 1d52442

Browse files
committed
Apply suggestions
1 parent 1bf27cd commit 1d52442

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

internal/core/api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use crate::window::{WindowAdapter, WindowInner};
1515
use alloc::boxed::Box;
1616
use alloc::string::String;
1717

18+
#[cfg(feature = "experimental-rich-text")]
1819
mod styled_text;
20+
#[cfg(feature = "experimental-rich-text")]
1921
pub use styled_text::*;
2022

2123
/// A position represented in the coordinate space of logical pixels. That is the space before applying

internal/core/api/styled_text.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
33

44
#[derive(Clone, Debug, PartialEq)]
5+
/// Styles that can be applied to text spans
56
#[allow(missing_docs)]
67
pub enum Style {
78
Emphasis,
@@ -14,31 +15,34 @@ pub enum Style {
1415
}
1516

1617
#[derive(Clone, Debug, PartialEq)]
17-
#[allow(missing_docs)]
18+
/// A style and a text span
1819
pub struct FormattedSpan {
20+
/// Span of text to style
1921
pub range: core::ops::Range<usize>,
22+
/// The style to apply
2023
pub style: Style,
2124
}
2225

23-
#[cfg(feature = "experimental-rich-text")]
2426
#[derive(Clone, Debug)]
2527
enum ListItemType {
2628
Ordered(u64),
2729
Unordered,
2830
}
2931

30-
#[cfg(feature = "experimental-rich-text")]
32+
/// A section of styled text, split up by a linebreak
3133
#[derive(Clone, Debug, PartialEq)]
32-
#[allow(missing_docs)]
3334
pub struct StyledTextParagraph {
35+
/// The raw paragraph text
3436
pub text: std::string::String,
37+
/// Formatting styles and spans
3538
pub formatting: std::vec::Vec<FormattedSpan>,
39+
/// Locations of clickable links within the paragraph
3640
pub links: std::vec::Vec<(std::ops::Range<usize>, std::string::String)>,
3741
}
3842

39-
#[cfg(feature = "experimental-rich-text")]
4043
#[derive(Debug, thiserror::Error)]
4144
#[allow(missing_docs)]
45+
#[non_exhaustive]
4246
pub enum StyledTextError<'a> {
4347
#[error("Spans are unbalanced: stack already empty when popped")]
4448
Pop,
@@ -64,14 +68,11 @@ pub enum StyledTextError<'a> {
6468

6569
/// Internal styled text type
6670
#[derive(Debug, PartialEq, Clone, Default)]
67-
#[allow(missing_docs)]
6871
pub struct StyledText {
69-
#[cfg(feature = "experimental-rich-text")]
72+
/// Paragraphs of styled text
7073
pub paragraphs: std::vec::Vec<StyledTextParagraph>,
7174
}
7275

73-
#[cfg(feature = "experimental-rich-text")]
74-
#[allow(missing_docs)]
7576
impl StyledText {
7677
fn begin_paragraph(&mut self, indentation: u32, list_item_type: Option<ListItemType>) {
7778
let mut text = std::string::String::with_capacity(indentation as usize * 4);
@@ -98,6 +99,7 @@ impl StyledText {
9899
});
99100
}
100101

102+
/// Parse a markdown string as styled text
101103
pub fn parse(string: &str) -> Result<Self, StyledTextError<'_>> {
102104
let parser =
103105
pulldown_cmark::Parser::new_ext(string, pulldown_cmark::Options::ENABLE_STRIKETHROUGH);
@@ -356,7 +358,6 @@ impl StyledText {
356358
}
357359
}
358360

359-
#[cfg(feature = "experimental-rich-text")]
360361
#[test]
361362
fn markdown_parsing() {
362363
assert_eq!(

0 commit comments

Comments
 (0)