refactor: modularize large files across codebase#188
Merged
Conversation
Split files over 500 lines into smaller, focused modules: Phase 1 - Binding crates: - Node.js: Split lib.rs into enums, handles, options, types/, visitor/ - Python: Split lib.rs into conversion/, handles, helpers, options, types/, visitor/ - PHP: Split lib.rs into build, enums, options, types - WASM: Split lib.rs into options, types - Ruby: Split lib.rs into conversion/, options, types, visitor/ - Elixir: Split lib.rs into conversion/, options, types, visitor/ Phase 2 - Core Rust engine: - Split converter/inline/semantic.rs into marks.rs and typography.rs - Split visitor_helpers/callbacks.rs into macros.rs, bridge.rs - Split options.rs into conversion.rs, inline_image.rs, preprocessing.rs - Split metadata.rs into collector.rs, config.rs, extraction.rs - Split hocr/converter.rs into core.rs, elements.rs, hierarchy.rs Phase 3 - FFI and CLI: - Split FFI visitor into callbacks_core.rs, lifecycle.rs, visitor_impl.rs - Split CLI main.rs into args.rs, convert.rs, output.rs, validators.rs All files now target ~500 lines max with single-responsibility modules.
Fixes RefCell already borrowed panic at text_node.rs:219:42 by ensuring visitor borrows are released before match statements. This prevents conflicts when walk_node recursively processes children that need to borrow the same visitor. Pattern applied across 15 files: - Release borrow in scoped block before match - Prevents nested borrows during recursive tree walking
The c_char import is only used in tests behind #[cfg(feature = "metadata")], so the import itself needs the same feature gate.
- Gate Arc import behind async-visitor feature in handles.rs - Gate metadata type imports behind metadata feature in types/mod.rs - Gate metadata module imports behind metadata feature in metadata.rs
6f3ff05 to
f68ac36
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 1 - Binding crates
Phase 2 - Core Rust engine
Phase 3 - FFI and CLI
Test plan
prek run --all-files)🤖 Generated with Claude Code