Conversation
Reviewer's GuideThis PR enriches Token’s documentation by elaborating on its lifetime parameter and refactors the Class diagram for Token documentation updateclassDiagram
class Token {
<<lifetime 'a>>
+fields tied to source text
+used for custom wrapping logic
}
%% The diagram highlights the lifetime parameter and its purpose as clarified in the documentation.
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Summary by CodeRabbit
WalkthroughDocument the re-exported Changes
Sequence Diagram(s)Not applicable; no new features or control flow changes introduced. Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (1)**/*.rs📄 CodeRabbit Inference Engine (AGENTS.md)
Files:
⚙️ CodeRabbit Configuration File
Files:
🪛 GitHub Check: build-testsrc/html.rs[failure] 115-115: 🪛 GitHub Actions: CIsrc/html.rs[error] 115-115: Clippy lint error: this 🔇 Additional comments (3)
✨ 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. 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 - here's some feedback:
- The new
assert_eq!macro usage relies on unstableletexpressions and is causing compilation failures—consider rewriting the custom message syntax so it compiles on stable Rust. - The formatting-only expansion of the
is_fencefunction doesn’t add any semantic value and diverges from similar one-liners; consider reverting it or applying the same style across all small utility functions. - You can simplify the custom assertion by dropping the redundant named parameters and using the placeholders (
{expected:?}and{out:?}) directly in the format string.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `assert_eq!` macro usage relies on unstable `let` expressions and is causing compilation failures—consider rewriting the custom message syntax so it compiles on stable Rust.
- The formatting-only expansion of the `is_fence` function doesn’t add any semantic value and diverges from similar one-liners; consider reverting it or applying the same style across all small utility functions.
- You can simplify the custom assertion by dropping the redundant named parameters and using the placeholders (`{expected:?}` and `{out:?}`) directly in the format string.
## Individual Comments
### Comment 1
<location> `src/wrap.rs:171` </location>
<code_context>
#[doc(hidden)]
-pub fn is_fence(line: &str) -> bool { FENCE_RE.is_match(line) }
+pub fn is_fence(line: &str) -> bool {
+ FENCE_RE.is_match(line)
+}
</code_context>
<issue_to_address>
The function `is_fence` was previously a single-line function and did not require a block; the change introduces unnecessary verbosity.
Since `is_fence` is a simple wrapper, it can remain a single-line function without braces or an explicit `return`. Please revert to the concise form unless you plan to add more logic.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/wrap.rs(2 hunks)tests/wrap_renumber.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/wrap_renumber.rssrc/wrap.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/wrap_renumber.rssrc/wrap.rs
🪛 GitHub Actions: CI
src/wrap.rs
[warning] 168-170: Prettier formatting check failed. Diff detected in function formatting. Run 'cargo fmt --all' to fix code style issues.
🔇 Additional comments (2)
src/wrap.rs (1)
18-21: Improve! Public-facing docs now clearly explain the purpose of'a.The added explanation makes the token’s lifetime requirements explicit and removes any ambiguity for downstream users. Good job.
tests/wrap_renumber.rs (1)
16-22: Swap the arguments inassert_eq!so the error message aligns with macro output.
assert_eq!(left, right, …)prints left as “left” and right as “right”.
Currentlyoutis left but the custom message labels it “actual”. Reverse the operands to keep diagnostics consistent and remove the redundant named arguments.-assert_eq!( - out, - expected, - "renumbered output mismatch:\nexpected: {expected:?}\nactual: {out:?}", - expected = expected, - out = out, -); +assert_eq!( + expected, + out, + "renumbered output mismatch:\nexpected: {expected:?}\nactual: {out:?}" +);Likely an incorrect or invalid review comment.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
src/html.rs(2 hunks)src/wrap.rs(2 hunks)tests/wrap_renumber.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit Inference Engine (AGENTS.md)
**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider usingArcto reduce the amount of data returned.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessarymutbindings.
Handle errors with theResulttype instead of panicking where feasible.
Avoidunsafecode unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not usereturnin single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Preferexpectoverallow.
Prefer.expect()over.unwrap().
Useconcat!()to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derivestd::error::Error(via thethiserrorcrate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Useeyre::Reportfor human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and toeyreonly in the mainmain()entrypoint or top-level async task.
Files:
tests/wrap_renumber.rssrc/html.rssrc/wrap.rs
⚙️ CodeRabbit Configuration File
**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.
Adhere to single responsibility and CQRS
Place function attributes after doc comments.
Do not use
returnin single-line functions.Move conditionals with >2 branches into a predicate function.
Avoid
unsafeunless absolutely necessary.Every module must begin with a
//!doc comment that explains the module's purpose and utility.Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar
Lints must not be silenced except as a last resort.
#[allow]is forbidden.- Only narrowly scoped
#[expect(lint, reason = "...")]is allowed.- No lint groups, no blanket or file-wide suppression.
- Include
FIXME:with link if a fix is expected.Use
rstestfixtures for shared setup and to avoid repetition between tests.Replace duplicated tests with
#[rstest(...)]parameterised cases.Prefer
mockallfor mocks/stubs.Prefer
.expect()over.unwrap()Ensure that any API or behavioural changes are reflected in the documentation in
docs/Ensure that any completed roadmap steps are recorded in the appropriate roadmap in
docs/Files must not exceed 400 lines in length
- Large modules must be decomposed
- Long match statements or dispatch tables should be decomposed by domain and collocated with targets
- Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.
Files:
tests/wrap_renumber.rssrc/html.rssrc/wrap.rs
🔇 Additional comments (4)
src/html.rs (1)
87-89: Revert to single-line format.This simple boolean expression doesn't require multi-line formatting. The coding guidelines state "Do not use
returnin single-line functions" - keep this as a concise single-line function.-fn is_table_cell(handle: &Handle) -> bool { - is_element(handle, "td") || is_element(handle, "th") -} +fn is_table_cell(handle: &Handle) -> bool { is_element(handle, "td") || is_element(handle, "th") }Likely an incorrect or invalid review comment.
src/wrap.rs (2)
18-21: Excellent documentation improvement.The detailed doc comment clearly explains the
Token<'a>type's purpose and the significance of the lifetime parameter. This addresses the coding guideline requirement to document public APIs with Rustdoc comments.
170-173: Documentation and formatting are now correct.The function has proper documentation explaining its purpose, the
#[doc(hidden)]attribute is correctly placed after the doc comment, and the function maintains single-line format as required by the coding guidelines.tests/wrap_renumber.rs (1)
16-19: Excellent test diagnostic improvement.Enhanced assertion message provides clear debugging information showing expected vs actual output when the test fails. This improvement aids in troubleshooting without affecting test logic.
f906919 to
fc22bbc
Compare
Summary
Testing
make fmtmake lint(fails: error[E0658]:letexpressions in this position are unstable)make test(fails: error[E0658]:letexpressions in this position are unstable)https://chatgpt.com/codex/tasks/task_e_688ffa9ebe2c832295b62ee182f46073
Summary by Sourcery
Improve documentation for Token by explaining its lifetime linkage to source text and enhance wrap renumbering tests with custom assertion messages
Enhancements: