Implement builder defaults and expand fence tests#110
Conversation
Reviewer's GuideThis PR introduces Default and builder methods for Options to streamline configuration, refactors attach_orphan_specifiers into a single-pass algorithm, updates example docs for fence normalization, and expands fence testing (mixed tilde/backtick and orphan specifier cases), including a new CLI tilde-fence test. Class diagram for updated Options struct with builder methods and DefaultclassDiagram
class Options {
+bool wrap
+bool ellipsis
+bool fences
+bool footnotes
+with_wrap(wrap: bool) Options
+with_ellipsis(ellipsis: bool) Options
+with_fences(fences: bool) Options
+with_footnotes(footnotes: bool) Options
+default() Options
}
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughRefactor the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Processor
participant Fences
User->>CLI: Run mdtablefix with --fences and input
CLI->>Processor: Call process_stream with Options::default().with_fences(true)
Processor->>Fences: Call attach_orphan_specifiers on input lines
Fences-->>Processor: Return processed lines
Processor-->>CLI: Output normalised markdown
CLI-->>User: Display result
Possibly related issues
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.rsInstructions used from: Sources:
⚙️ CodeRabbit Configuration File 🔇 Additional comments (6)
✨ Finishing Touches
🧪 Generate unit tests
🪧 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 (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/process.rs:29` </location>
<code_context>
pub footnotes: bool,
}
+impl Options {
+ /// Set `wrap` option and return the updated struct.
+ #[must_use]
</code_context>
<issue_to_address>
Consider removing the redundant with_* setter methods and using struct update syntax with Default when modifying Options fields.
```rust
// 1. Drop the entire `impl Options { … }` block; the four `with_*` setters are redundant.
// 2. Use struct update syntax with Default where you need to tweak a flag:
// Before:
pub fn process_stream(lines: &[String]) -> Vec<String> {
process_stream_inner(lines, Options::default().with_wrap(true))
}
// After:
pub fn process_stream(lines: &[String]) -> Vec<String> {
process_stream_inner(lines, Options { wrap: true, ..Default::default() })
}
// Likewise, `process_stream_no_wrap` can just call `Default::default()`:
pub fn process_stream_no_wrap(lines: &[String]) -> Vec<String> {
process_stream_inner(lines, Options::default())
}
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (3)
README.md (1)
122-128: Align example with stated behaviour – enablefootnotesor fix the proseThe snippet now turns on
wrap,ellipsis, andfences, yet the paragraph later on claims that footnote conversion is enabled. Prevent reader confusion by either adding the flag below or amending the documentation text.- fences: true, - ..Default::default() + fences: true, + footnotes: true, + ..Default::default()src/process.rs (2)
17-27: Shrink the trait surface – dropCopy
Optionsis four booleans; cloning is effectively free. DerivingCopysilently spreads implicit copies and can mask bugs that rely on move semantics. RetainCloneandDefaultonly.-#[derive(Clone, Copy, Default)] +#[derive(Clone, Default)]
111-116: LeverageOptions::default()consistentlyMaintain stylistic unity and guard against future field additions by updating from the actual default rather than an ad-hoc literal.
- Options { - wrap: true, - ..Default::default() - }, + Options { wrap: true, ..Options::default() },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
README.md(1 hunks)src/process.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md
Instructions used from:
Sources:
⚙️ CodeRabbit Configuration File
**/*.rs
Instructions used from:
Sources:
⚙️ CodeRabbit Configuration File
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
src/process.rs(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
Instructions used from:
Sources:
📄 CodeRabbit Inference Engine
- AGENTS.md
⚙️ CodeRabbit Configuration File
🔇 Additional comments (1)
src/process.rs (1)
17-17: DeriveDefaultis spot-on
AddingDefaultlets callers rely on zero-cost initialisation and removes the need for redundant builder setters.
Summary
Defaultand builder methodsattach_orphan_specifiersto a single pass implementationTesting
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_687ce8f4297c8322a85deb0e824cd4c5
Summary by Sourcery
Simplify and unify Options construction with Default and builder methods, refactor fence handling to a single-pass approach, normalize documentation example, and expand fence-related test coverage
Bug Fixes:
Enhancements:
Documentation:
Tests: