Skip to content

Commit 91da067

Browse files
artizclaude
andcommitted
wasm: fix workspace clippy — PdfPage::from_cells absorbs the ml image field
The workspace-wide clippy job unifies features: docling-cli enables docling-pdf/ml alongside docling-wasm, so PdfPage grows its ml-gated `image` field and docling-wasm's struct literal stopped compiling (E0063). A cfg-aware constructor (from_cells, under ocr-prep) spells the field only when it exists; the browser pipeline builds its pages through it. Verified with the CI command verbatim (cargo clippy --workspace --all-targets -- -D warnings) plus the wasm32 target check. Refs #157 Signed-off-by: artiz <artem.kustikov@gmail.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EY5KAiquN4YpVf2PXEQkVT
1 parent afd7291 commit 91da067

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

crates/docling-pdf/src/pdfium_backend.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ pub struct PdfPage {
5353
pub links: Vec<LinkAnnot>,
5454
}
5555

56+
impl PdfPage {
57+
/// A page built from recognized cells alone — the browser pipeline's
58+
/// shape (#157), where the bitmap lives on the JS side. Exists so callers
59+
/// compile identically with and without the `ml` feature: under a
60+
/// feature-unified workspace build the struct carries the `image` field,
61+
/// which a plain literal in a non-`ml` consumer can't spell.
62+
#[cfg(feature = "ocr-prep")]
63+
pub fn from_cells(width: f32, height: f32, scale: f32, cells: Vec<TextCell>) -> Self {
64+
Self {
65+
width,
66+
height,
67+
scale,
68+
cells,
69+
code_cells: Vec::new(),
70+
word_cells: Vec::new(),
71+
#[cfg(feature = "ml")]
72+
image: RgbImage::new(0, 0),
73+
links: Vec::new(),
74+
}
75+
}
76+
}
77+
5678
/// A PDF link annotation: its rectangle (top-left page coordinates, matching
5779
/// [`TextCell`]) and target URI.
5880
#[derive(Debug, Clone)]

crates/docling-wasm/src/scanned.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,7 @@ impl ScannedConverter {
138138
cells.push(TextCell { text, l, t, r, b });
139139
}
140140

141-
let page = PdfPage {
142-
width: page_w,
143-
height: page_h,
144-
scale,
145-
cells,
146-
code_cells: Vec::new(),
147-
word_cells: Vec::new(),
148-
links: Vec::new(),
149-
};
141+
let page = PdfPage::from_cells(page_w, page_h, scale, cells);
150142
self.pages.push(assemble_page(&page, regions));
151143
Ok(())
152144
}

0 commit comments

Comments
 (0)