Conversation
Reviewer's GuideRefactors the text processing pipeline to make wrapping opt-in via a new Sequence Diagram: Conditional Text Processing with --wrap FlagsequenceDiagram
actor User
participant CLI_Main as "CLI (main.rs)"
participant Lib_PublicAPI as "lib.rs (Functions)"
participant Lib_Inner as "lib.rs (process_stream_inner)"
User->>CLI_Main: Executes mdtablefix (optional --wrap)
CLI_Main->>CLI_Main: Parses arguments (sets wrap_flag)
alt wrap_flag is true
CLI_Main->>Lib_PublicAPI: Calls wrapping function (e.g., process_stream or rewrite)
Lib_PublicAPI->>Lib_Inner: process_stream_inner(data, true)
Lib_Inner-->>Lib_PublicAPI: Wrapped lines
Lib_PublicAPI-->>CLI_Main: Result with wrapped lines
else wrap_flag is false
CLI_Main->>Lib_PublicAPI: Calls non-wrapping function (e.g., process_stream_no_wrap or rewrite_no_wrap)
Lib_PublicAPI->>Lib_Inner: process_stream_inner(data, false)
Lib_Inner-->>Lib_PublicAPI: Non-wrapped lines
Lib_PublicAPI-->>CLI_Main: Result with non-wrapped lines
end
CLI_Main->>User: Outputs processed text
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
WalkthroughThis update introduces a Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Library
User->>CLI: Run mdtablefix [--wrap] [file]
CLI->>CLI: Parse CLI arguments
alt --wrap is set
CLI->>Library: process_stream / rewrite (with wrapping)
else --wrap not set
CLI->>Library: process_stream_no_wrap / rewrite_no_wrap (no wrapping)
end
Library-->>CLI: Processed output
CLI-->>User: Output to stdout or file
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Docstrings generation was requested by @leynos. * #38 (comment) The following files were modified: * `src/html.rs` * `src/lib.rs` * `src/main.rs` * `tests/integration.rs`
|
Note Generated docstrings for this pull request at #39 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main.rs (1)
47-52: Minor duplication – extract helper to reduce branchingThe
if cli.wrap { … } else { … }block appears three times. Extracting a small helper (e.g.fn process(lines: &[String], wrap: bool) -> Vec<String>) would remove repetition and make future adjustments (different widths, etc.) less error-prone.Pure refactor; no functional bug.
Also applies to: 58-63, 66-71
src/html.rs (1)
215-225: Public exposure of internal helper twice
html_table_to_markdownis nowpub #[doc(hidden)]and re-exported at the crate root with the same visibility. This leaks the symbol via two paths (mdtablefix::html::html_table_to_markdownandmdtablefix::html_table_to_markdown). If complete hiding is the goal, consider:-#[doc(hidden)] -pub fn html_table_to_markdown(…) +pub(crate) fn html_table_to_markdown(…)and keep only the crate-level re-export tagged with
#[doc(hidden)].
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
README.md(2 hunks)src/html.rs(2 hunks)src/lib.rs(8 hunks)src/main.rs(3 hunks)tests/integration.rs(1 hunks)
🔇 Additional comments (2)
README.md (1)
4-5: Documentation update looks goodThe README now accurately reflects the opt-in behaviour via
--wrap. No further issues spotted.Also applies to: 24-29
src/lib.rs (1)
505-513: Wrapper functions read cleanly
process_stream/process_stream_no_wrapcorrectly delegate to the shared inner helper. Nice separation of concerns.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
--wrap--wrapusage in READMEprocess_stream_no_wrapandrewrite_no_wrapTesting
cargo fmtcargo clippy -- -D warningsRUSTFLAGS="-D warnings" cargo testmarkdownlint README.mdhttps://chatgpt.com/codex/tasks/task_e_684e4d1908988322aabbcb892045e7a4
Summary by Sourcery
Add an optional wrapping flag to make text wrapping opt-in and provide no-wrap variants for processing and in-place rewriting
New Features:
--wrapCLI option to enable paragraph and list wrappingprocess_stream_no_wrapandrewrite_no_wrapto skip wrappingEnhancements:
Documentation:
--wrapusage in READMETests:
--wrapoptionSummary by CodeRabbit
--wrapto control paragraph and list item wrapping to 80 columns.--wrapoption.--wrapcommand-line option.