Skip to content

Route Word 97 binary parsing through craft-libs - #6565

Merged
dylanmtaylor merged 3 commits into
storytold:mainfrom
dylanmtaylor:codex/docbin-craft-libs
Nov 13, 2026
Merged

dylanmtaylor merged 3 commits into
storytold:mainfrom
dylanmtaylor:codex/docbin-craft-libs

Conversation

@dylanmtaylor

@dylanmtaylor dylanmtaylor commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Move native .doc parsing and encryption detection into craft-doc-binary. WordCraft keeps the public read API and maps the shared neutral model into its app model.

The app-local parser and its wire-specific tests are removed after matching parser coverage was confirmed in craft-doc-binary / craft-cfb. Adapter tests cover compressed and UTF-16 documents, malformed containers, nested stories, large paragraph text, and moving media buffers without copying.

Validation

  • cargo test -p wordcraft-docbin -- --nocapture
  • cargo clippy -p wordcraft-docbin --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check

Summary by CodeRabbit

  • Refactor
    • DOC file reading now uses a shared document-reading engine, with imported content converted into the app’s document format.
    • The existing document-reading entry points, including the password-aware option, remain available.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The docbin crate now delegates DOC reading to craft-doc-binary and converts its shared document model into wordcraft_doc::Document. The change removes the in-crate parser modules and their dedicated encryption, drawing, and metadata tests.

Changes: DOC reader migration

Layer / File(s) Summary
Shared-model conversion
crates/docbin/Cargo.toml, crates/docbin/src/model_bridge.rs
Adds pinned shared-reader dependencies and JSON-based conversion for document content, nested structures, persistent fields, media, and passthrough data. Tests cover nested content, settings, media pointer identity, and default fit state.
Reader delegation and read tests
crates/docbin/src/lib.rs, crates/docbin/src/tests.rs
Delegates reads and encryption checks to craft-doc-binary. Tests cover non-compound input and compressed, CP1252, and UTF-16 text extraction.
Binary parsing and formatting module removal
crates/docbin/src/fib.rs, crates/docbin/src/piece.rs, crates/docbin/src/sprm.rs, crates/docbin/src/fkp.rs, crates/docbin/src/stsh.rs, crates/docbin/src/fmt.rs
Removes local FIB, piece-table, sprm, formatting-page, style, and stylesheet parsing.
Document structure parsing removal
crates/docbin/src/list.rs, crates/docbin/src/notes.rs, crates/docbin/src/table.rs, crates/docbin/src/sections.rs
Removes local numbering, note and bookmark, table, and section parsing.
Encryption, drawing, media, and metadata removal
crates/docbin/src/crypt.rs, crates/docbin/src/drawing.rs, crates/docbin/src/media.rs, crates/docbin/src/officeart.rs, crates/docbin/src/metadata.rs, crates/docbin/src/tests/drawing.rs, crates/docbin/src/tests/encrypted.rs, crates/docbin/src/tests/metadata.rs
Removes local encryption, drawing, picture, OfficeArt, and SummaryInformation parsing, plus the corresponding dedicated tests.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant read_with_password
  participant craft_doc_binary
  participant from_shared_model
  participant wordcraft_doc_Document
  Caller->>read_with_password: bytes and optional password
  read_with_password->>craft_doc_binary: read document
  craft_doc_binary-->>read_with_password: shared document model
  read_with_password->>from_shared_model: convert shared model
  from_shared_model-->>wordcraft_doc_Document: converted document
Loading

Suggested reviewers: edurbs, benandez

Merge Risk: Minimal · up to 388c8

Word 97 .doc parsing now runs through the shared craft-libs reader, while WordCraft keeps its existing read API. Document content and metadata such as title, author and page setup carry over in the conversion to WordCraft's document model. No merge-blocking issues were found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Route Word 97 binary parsing through craft-libs" matches the main change. The PR moves native .doc parsing and encryption detection out of the crate and into craft-doc-binary, and the diff …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Route Word 97 binary parsing through craft-libs" matches the main change. The PR moves native .doc parsing and encryption detection out of the crate and into craft-doc-binary, and the diff deletes the local parser modules (fib, piece, fkp, sprm, and others) while lib.rs becomes an adapter to the shared reader. The title is short, specific, and avoids file lists. It names the "craft-libs" destination, which is accurate per the PR objectives.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between eae8363 and 388c8e5.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 22

  • crates/docbin/Cargo.toml
  • crates/docbin/src/crypt.rs
  • crates/docbin/src/drawing.rs
  • crates/docbin/src/fib.rs
  • crates/docbin/src/fkp.rs
  • crates/docbin/src/fmt.rs
  • crates/docbin/src/lib.rs
  • crates/docbin/src/list.rs
  • crates/docbin/src/media.rs
  • crates/docbin/src/metadata.rs
  • crates/docbin/src/model_bridge.rs
  • crates/docbin/src/notes.rs
  • crates/docbin/src/officeart.rs
  • crates/docbin/src/piece.rs
  • crates/docbin/src/sections.rs
  • crates/docbin/src/sprm.rs
  • crates/docbin/src/stsh.rs
  • crates/docbin/src/table.rs
  • crates/docbin/src/tests.rs
  • crates/docbin/src/tests/drawing.rs
  • crates/docbin/src/tests/encrypted.rs
  • crates/docbin/src/tests/metadata.rs
Files with no reviewable changes: 18

  • crates/docbin/src/crypt.rs
  • crates/docbin/src/drawing.rs
  • crates/docbin/src/fib.rs
  • crates/docbin/src/fkp.rs
  • crates/docbin/src/fmt.rs
  • crates/docbin/src/list.rs
  • crates/docbin/src/media.rs
  • crates/docbin/src/metadata.rs
  • crates/docbin/src/notes.rs
  • crates/docbin/src/officeart.rs
  • crates/docbin/src/piece.rs
  • crates/docbin/src/sections.rs
  • crates/docbin/src/sprm.rs
  • crates/docbin/src/stsh.rs
  • crates/docbin/src/table.rs
  • crates/docbin/src/tests/drawing.rs
  • crates/docbin/src/tests/encrypted.rs
  • crates/docbin/src/tests/metadata.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant