Skip to content

Commit c6be69e

Browse files
committed
fix(issues): add empty flaws for --json-issues
1 parent 789f813 commit c6be69e

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

Diff for: crates/rari-doc/src/build.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,15 @@ pub fn build_single_page(page: &Page) -> Result<(BuiltPage, String), DocError> {
7171
let mut built_page = page.build()?;
7272
if settings().json_issues {
7373
if let BuiltPage::Doc(json_doc) = &mut built_page {
74-
if let Some(issues) = IN_MEMORY
74+
let flaws = if let Some(issues) = IN_MEMORY
7575
.get_events()
7676
.get(page.full_path().to_string_lossy().as_ref())
7777
{
78-
json_doc.doc.flaws = Some(to_display_issues(issues.value().clone(), page));
79-
}
78+
Some(to_display_issues(issues.value().clone(), page))
79+
} else {
80+
Some(Default::default())
81+
};
82+
json_doc.doc.flaws = flaws;
8083
}
8184
}
8285
let out_path = build_out_root()

Diff for: crates/rari-doc/src/helpers/l10n.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ static JSON_L10N_FILES: LazyLock<HashMap<String, JsonL10nFile>> = LazyLock::new(
4747
if f.path().is_file()
4848
&& f.path()
4949
.extension()
50-
.map_or(false, |ext| ext.eq_ignore_ascii_case("json"))
50+
.is_some_and(|ext| ext.eq_ignore_ascii_case("json"))
5151
&& f.path()
5252
.file_stem()
5353
.and_then(|s| s.to_str())
54-
.map_or(false, |s| s.starts_with("L10n-"))
54+
.is_some_and(|s| s.starts_with("L10n-"))
5555
{
5656
return Some(f.path());
5757
}

Diff for: crates/rari-md/src/p.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use crate::ext::{DELIM_END, DELIM_START};
55
fn only_escaped_templ(b: &[u8], start: usize) -> bool {
66
let b = b.trim_ascii_end();
77
if b[start..].starts_with(DELIM_START.as_bytes()) {
8-
let start = start + DELIM_START.as_bytes().len();
8+
let start = start + DELIM_START.len();
99
if let Some(end) = b[start..]
10-
.windows(DELIM_END.as_bytes().len())
10+
.windows(DELIM_END.len())
1111
.position(|window| window == DELIM_END.as_bytes())
1212
{
13-
if start + end + DELIM_END.as_bytes().len() == b.len() {
13+
if start + end + DELIM_END.len() == b.len() {
1414
return true;
1515
} else {
16-
return only_escaped_templ(b, start + end + DELIM_END.as_bytes().len());
16+
return only_escaped_templ(b, start + end + DELIM_END.len());
1717
}
1818
}
1919
}

0 commit comments

Comments
 (0)