Refactor attach_orphan_specifiers; add attach_to_next_fence helper#273
Refactor attach_orphan_specifiers; add attach_to_next_fence helper#273
Conversation
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughRefactor orphan-specifier handling to use a Peekable iterator and delegate lookahead/attachment to Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(220,230,241,0.5)
participant Spec as "Orphan Specifier Line"
end
rect rgba(240,255,240,0.5)
participant Att as "attach_to_next_fence (Peekable)"
end
rect rgba(255,250,230,0.5)
participant Buf as "Buffered Blank Lines"
end
rect rgba(255,230,230,0.5)
participant Fence as "Next Non-Blank Line / Opening Fence"
end
rect rgba(245,245,245,0.5)
participant Out as "Output Stream"
end
Spec->>Att: invoke with specifier, spec_indent, specifier_line, tracker, out
Att->>Att: clone/peek and buffer intervening blank lines into Buf
Att->>Fence: peek next non-blank line
alt next is unlabeled opening fence (language null/empty)
Att->>Fence: consume fence line
Att->>Att: choose indentation (fence vs specifier rules)
Att->>Fence: rewrite fence line with appended specifier
Att->>Out: emit rewritten fence
Att->>Buf: discard buffered blanks
Att->>Fence: update FenceTracker (enter fence)
Att-->>Spec: return AttachmentOutcome::Attached
else no eligible fence found
Att->>Out: emit original specifier line
Att->>Out: emit buffered blank lines
Att->>Fence: leave FenceTracker unchanged
Att-->>Spec: return AttachmentOutcome::Preserved
end
Possibly related issues
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning, 5 inconclusive)
✅ Passed checks (11 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideRefactors attach_orphan_specifiers to iterate with a Peekable iterator instead of index-based access, inlining the orphan-specifier targeting logic while preserving existing behavior and improving handling of blank lines and fence attachment conditions. Class diagram for functions in fences module after refactorclassDiagram
class FencesModule {
+attach_orphan_specifiers(lines: Vec_String) Vec_String
+attach_specifier_to_fence(fence_line: str, specifier: str, spec_indent: str) String
-normalize_specifier(line: str) Tuple_String_String
-FENCE_RE Regex
-ORPHAN_LANG_RE Regex
-is_null_lang(lang: str) bool
}
class OrphanSpecifierHelpersOld {
-orphan_specifier_target(lines: Vec_String, start: usize) Option_usize
-orphan_specifier_target_without_language(lines: Vec_String, start: usize) Option_usize
}
FencesModule .. OrphanSpecifierHelpersOld : refactor_inlines_logic
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@coderabbitai re:
Is this not undesirable behaviour? It is also not requested by #102 |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainLet me fetch issue 🏁 Script executed: Length of output: 8357
It was not requested by It is also undesirable. The original documented behaviour was explicit:
The new code buffers those blank lines into Emitting those blank lines into the output means a blank line can appear between the orphan specifier position and its attached fence line, which is a rendered-Markdown observable change and almost certainly not what users expect. The fix should drop the buffered blank lines on a successful attachment (or simply not buffer them at all, matching the original skip-blank-lines semantics). Something along these lines: fn attach_to_next_fence<'a, I>(
lines: &mut std::iter::Peekable<I>,
specifier: &str,
indent: &str,
out: &mut Vec<String>,
specifier_line: &str,
) where
I: Iterator<Item = &'a String>,
{
let mut blank_lines: Vec<String> = Vec::new();
while let Some(next_line) = lines.peek() {
if next_line.trim().is_empty() {
if let Some(blank_line) = lines.next() {
blank_lines.push(blank_line.clone());
}
continue;
}
if let Some(captures) = FENCE_RE.captures(next_line) {
let lang = captures.get(3).map_or("", |m| m.as_str());
if is_null_lang(lang)
&& let Some(fence_line) = lines.next()
{
// Drop blank_lines — original behaviour skipped them.
out.push(attach_specifier_to_fence(fence_line, specifier, indent));
return;
}
}
break;
}
// No suitable fence found — emit the specifier and any blanks verbatim.
out.push(specifier_line.to_string());
out.extend(blank_lines);
}This restores the skip-blank-lines semantics on a successful attachment whilst still correctly emitting the original specifier line plus any blank lines when no eligible fence is found. |
|
@coderabbitai Have the following now been resolved? src/fences.rs (1)
📝 Proposed documentation update//! Pre-processing utilities for normalizing fenced code block delimiters.
//!
//! `compress_fences` reduces any sequence of three or more backticks or
//! tildes followed by optional language identifiers to exactly three
//! backticks.
-//! It preserves indentation and the language list.
+//! It preserves indentation and the language list.
+//!
+//! `attach_orphan_specifiers` reattaches language specifiers that appear on
+//! their own line before a fence, preserving any intervening blank lines.🤖 Prompt for AI Agents |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 887
Both functions are documented, satisfying the coding guideline. Note also that the text correctly omits any mention of blank-line preservation — consistent with the earlier discussion about restoring the skip-blank-lines semantics on successful attachment. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/fences.rs`:
- Around line 183-186: Update the Rustdoc sentence in the doc block that begins
"When the fence is unindented, the specifier's indentation..." to state that
successful attachment drops intervening blank lines rather than preserves them;
specifically, change the phrase "preserving any intervening blank lines" to
"dropping any intervening blank lines" so the description of fence attachment
behavior accurately reflects the implementation.
In `@tests/fences.rs`:
- Around line 203-208: Replace the duplicate test by converting the two similar
tests into a single parameterized rstest: remove the standalone test
attaches_orphan_specifier_drops_multiple_blank_lines_on_successful_attachment
and merge its input case with the existing compressed-flow blank-line test by
creating a #[rstest] function (e.g. fixes_orphaned_specifier_with_blank_lines)
that takes a #[case] input Vec<String>, add both inputs (one blank line and two
blank lines) as #[case(...)] attributes, and inside call compress_fences(&input)
then attach_orphan_specifiers(...) and assert_eq! against
lines_vec!["```rust","fn main() {}","```"]; this eliminates duplication while
keeping compress_fences and attach_orphan_specifiers behavior covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: fa5cae04-2928-4010-8a30-537816203225
📒 Files selected for processing (2)
src/fences.rstests/fences.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/fences.rs`:
- Around line 68-74: The test suite lacks a fallback case covering
attach_to_next_fence behavior when buffered blank lines follow an orphan
specifier but the next content is an already-labelled fence or plain text; add a
new rstest in tests/fences.rs that passes inputs like
["Rust","","","```python","print('hi')","```"] and ["Rust","","not a fence"]
through compress_fences and attach_orphan_specifiers and assert the output
equals the original input to ensure orphan specifier plus blank lines remain
unchanged; reference the existing test fixes_orphaned_specifier_with_blank_lines
to mirror structure and use attach_orphan_specifiers/compress_fences in the
assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 9d00aac1-ac2d-42ca-9415-28b76c4c0adb
📒 Files selected for processing (2)
src/fences.rstests/fences.rs
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/developers-guide.md`:
- Around line 109-111: The wording says "strictly extends" but the implemented
predicate is spec_indent.starts_with(fence_indent), which allows equal
indentation; update the prose to match the code by replacing "strictly extends"
with language like "is equal to or extends" (or "extends or is equal to") and
explicitly mention that equality is permitted so readers understand
spec_indent.starts_with(fence_indent) covers both equal and deeper indentation;
ensure the sentence referencing spec_indent.starts_with(fence_indent) remains
and adjust surrounding text for clarity.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: b616443f-e0e6-4007-9bd7-d1340540db30
📒 Files selected for processing (1)
docs/developers-guide.md
252b3b7 to
c2e1c1e
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/developers-guide.md`:
- Line 61: In the sentence fragment shown ("Together these helpers make the rest
of the processing pipeline deal with a"), add a comma after the preceding
sentence-ending word "fence" so the joined sentence reads "fence. Together,
these helpers ..."; edit the markdown line containing "Together these helpers"
to insert the comma after "Together" to produce "Together, these helpers" for
correct clause separation and improved readability.
- Line 58: Replace the redundant phrase "specifier lines that appear on their
own line before an unlabeled opening" with the concise wording "specifier lines
that appear on a separate line before an unlabelled opening fence"; locate the
existing sentence containing the exact original phrase and update it to the new
text, ensuring spelling uses "unlabelled" and "separate line" as requested.
- Around line 109-112: Update the sentence describing the indentation comparison
to use active voice and clearer wording: change "is equal to or extends" to
"matches or extends" and state that spec_indent.starts_with(fence_indent) checks
prefix membership (i.e., whether fence_indent is a prefix of spec_indent,
including equality). Replace "Equality is permitted here" with an active
phrasing such as "This allows equal indentation" and keep the explanation that
the same predicate covers both matching and deeper indentation. Ensure the
updated text references the method spec_indent.starts_with(fence_indent) exactly
so readers can locate the check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: bfb0d4c1-eb21-4a09-beca-75faff8e636e
📒 Files selected for processing (2)
README.mddocs/developers-guide.md
There was a problem hiding this comment.
♻️ Duplicate comments (1)
docs/developers-guide.md (1)
102-106:⚠️ Potential issue | 🟡 MinorUse en-GB spelling and fix clause punctuation in this paragraph.
Replace
unlabeledwithunlabelled, and add the comma afterTogetherfor consistency and readability.📝 Proposed doc patch
- specifier lines that appear on their own line before an unlabeled opening + specifier lines that appear on their own line before an unlabelled opening fence. -Together these helpers make the rest of the processing pipeline deal with a +Together, these helpers make the rest of the processing pipeline deal with aTriage:
[type:spelling][type:syntax/md][type:docstyle]As per coding guidelines: "
docs/**/*.{md,rst,txt}: Use British English based on Oxford English Dictionary locale (en-GB)" and "docs/**/*.md: Follow markdownlint recommendations for Markdown files."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/developers-guide.md` around lines 102 - 106, Update the paragraph text to use en-GB spelling and fix punctuation: change the word "unlabeled" to "unlabelled" in the sentence containing "specifier lines that appear on their own line before an unlabeled opening fence." and insert a comma after the word "Together" at the start of the following sentence so it reads "Together, these helpers..."; ensure no other wording changes are made.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@docs/developers-guide.md`:
- Around line 102-106: Update the paragraph text to use en-GB spelling and fix
punctuation: change the word "unlabeled" to "unlabelled" in the sentence
containing "specifier lines that appear on their own line before an unlabeled
opening fence." and insert a comma after the word "Together" at the start of the
following sentence so it reads "Together, these helpers..."; ensure no other
wording changes are made.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7fc3bd19-7d93-4efc-9878-2d108d3e6ae4
📒 Files selected for processing (4)
README.mddocs/developers-guide.mdsrc/fences.rstests/fences.rs
c2e1c1e to
570b912
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (2)
docs/developers-guide.md (2)
221-224: 🧹 Nitpick | 🔵 TrivialClarify indentation predicate wording.
The phrase "is equal to or extends" is slightly awkward. Rephrase to use active voice and clarify the
starts_withsemantics.Triage:
[type:docstyle]📝 Proposed revision
-- If the specifier's indentation is equal to or extends the fence's, checked - via `spec_indent.starts_with(fence_indent)`, the specifier indentation is - used. Equality is permitted here, so the same predicate covers both matching - and deeper indentation. +- If the specifier's indentation matches or extends the fence's indentation, + checked via `spec_indent.starts_with(fence_indent)`, the specifier + indentation is used. The `starts_with` predicate permits equality, so the + same check covers both matching and deeper indentation.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/developers-guide.md` around lines 221 - 224, Rewrite the sentence to use active voice and clearly explain the predicate: state that if spec_indent starts_with fence_indent then the specifier’s indentation is considered to extend (or be the same as) the fence’s indentation and therefore is used; mention that equality is allowed so the predicate covers both exact matches and deeper (longer) indentations and reference the symbols spec_indent, fence_indent, and starts_with in the sentence for clarity.
173-175:⚠️ Potential issue | 🟡 MinorInsert comma after "fence" for clause separation.
Add a comma after "fence." to separate the two independent statements.
Triage:
[type:grammar]📝 Proposed fix
-Together these helpers make the rest of the processing pipeline deal with a +Together, these helpers make the rest of the processing pipeline deal with a🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/developers-guide.md` around lines 173 - 175, The sentence "Together these helpers make the rest of the processing pipeline deal with a single normalized fence form and avoid carrying separate logic for detached specifier lines." needs a comma after "fence" to separate the two independent clauses; update the sentence so it reads "...deal with a single normalized fence, form and avoid..." — actually place the comma immediately after "fence" in the phrase "single normalized fence form" to produce "single normalized fence, form" to satisfy the reviewer comment (adjust surrounding wording if needed to keep grammatical sense while inserting the comma next to the token "fence").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/developers-guide.md`:
- Around line 170-171: Replace the US spelling "unlabeled" with the
en-GB-oxendict spelling "unlabelled" in the sentence containing "unlabeled
opening fence" (the phrase starting "specifier lines that appear on their own
line before an unlabeled opening fence"); locate the token "unlabeled" in
docs/developers-guide.md and update it to "unlabelled" (and run a quick grep for
other occurrences of "unlabeled" in the repo to ensure consistency).
---
Duplicate comments:
In `@docs/developers-guide.md`:
- Around line 221-224: Rewrite the sentence to use active voice and clearly
explain the predicate: state that if spec_indent starts_with fence_indent then
the specifier’s indentation is considered to extend (or be the same as) the
fence’s indentation and therefore is used; mention that equality is allowed so
the predicate covers both exact matches and deeper (longer) indentations and
reference the symbols spec_indent, fence_indent, and starts_with in the sentence
for clarity.
- Around line 173-175: The sentence "Together these helpers make the rest of the
processing pipeline deal with a single normalized fence form and avoid carrying
separate logic for detached specifier lines." needs a comma after "fence" to
separate the two independent clauses; update the sentence so it reads "...deal
with a single normalized fence, form and avoid..." — actually place the comma
immediately after "fence" in the phrase "single normalized fence form" to
produce "single normalized fence, form" to satisfy the reviewer comment (adjust
surrounding wording if needed to keep grammatical sense while inserting the
comma next to the token "fence").
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f2bcbc7f-5bad-4fea-acb9-d40c7dafa88f
📒 Files selected for processing (4)
README.mddocs/developers-guide.mdsrc/fences.rstests/fences.rs
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/developers-guide.md`:
- Around line 170-173: Change the phrasing and punctuation in the developers
guide: in the sentence describing attach_orphan_specifiers replace "their own
line" with "a separate line" to remove redundant ownership wording, and insert a
comma after the introductory adverb "Together" so the sentence reads "Together,
these helpers make the rest of the processing pipeline..." ensuring the doc line
referring to attach_orphan_specifiers uses the new wording and the following
sentence gains the comma.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 5c64c285-917c-4af9-b5c6-086c778622c4
📒 Files selected for processing (1)
docs/developers-guide.md
|
@coderabbitai Have the following now been resolved? Annul any requirements that violate the en-GB-oxendict spelling (-ize / -yse / -our) conventions (for example a request to replace "normalize" with "normalise" or "artefact" with "artifact"), or where the requirement unnecessarily increases cyclomatic complexity. |
|
@coderabbitai Have the following now been resolved? src/fences.rs (1)
📝 Proposed documentation update//! Pre-processing utilities for normalizing fenced code block delimiters.
//!
//! `compress_fences` reduces any sequence of three or more backticks or
//! tildes followed by optional language identifiers to exactly three
//! backticks.
-//! It preserves indentation and the language list.
+//! It preserves indentation and the language list.
+//!
+//! `attach_orphan_specifiers` reattaches language specifiers that appear on
+//! their own line before a fence, preserving any intervening blank lines.🤖 Prompt for AI Agents |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 7730
Overall comment — blank-line handling Individual Comment 1 — cyclomatic complexity / No en-GB-oxendict or complexity annulments are required: |
Previously, blank lines between a specifier line and the following opening fence were preserved. This change updates the behavior to drop any intervening blank lines when attaching the specifier to the fence. Corresponding tests were updated and parameterized to cover multiple blank lines scenarios. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Add parameterized tests to verify that orphan specifiers and blank lines remain unchanged when they are not attachable. This ensures the function attach_orphan_specifiers correctly handles these cases without modifying the input. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
This update adds comprehensive documentation for the `fences` module in the developers guide, explaining its purpose, public APIs, architecture, internal helper semantics, and indentation logic. The new guide helps maintainers and contributors understand how fenced code blocks are normalized and processed, facilitating future improvements and maintenance. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
…handling - Improved explanation of `--fences` option in README.md to detail normalization of fenced code block delimiters, preservation of indentation and language identifiers, and handling of orphan language specifiers. - Refined developers guide to specify that specifier indentation equal to or extending fence indentation is considered, improving clarity on indentation rules for fenced blocks. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Corrected spelling of 'unlabelled' in code comment to match style. Improved wording in the explanation of indentation handling for fenced blocks. These changes improve clarity and consistency in the developers guide documentation. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Refined phrasing for clarity: - Changed 'on their own line' to 'on a separate line' - Added a missing comma after 'Together' These changes enhance the readability of code documentation without altering functionality. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Introduce a new feature to normalize fenced code blocks by reducing delimiter runs to exactly three backticks while preserving indentation and language identifiers. Implement logic to attach language specifiers on separate lines to the following unlabelled opening fence, removing blank lines between when appropriate. Add documentation in users-guide.md describing the new --fences option and fence normalization behavior. Include comprehensive tests for the specifier attachment functionality to ensure correct handling of blank lines and preservation of existing labels. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
…metrization Refactored multiple individual tests for attach_to_next_fence into a single parameterized test using rstest to improve test clarity and reduce code duplication. Additionally, updated documentation wording for fence normalization for clarity. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
…specifier line Extended explanation in the users-guide to specify that if no suitable fence follows a language specifier line, that line along with any intervening blank lines are left unchanged, preserving document spacing. Co-authored-by: devboxerhub[bot] <devboxerhub[bot]@users.noreply.github.com>
Keep the internal fence helper tests behind `#[cfg(test)]` and restore lost `rstest` and `test` attributes in the integration tests. These markers are required for the rebased branch to compile with warnings denied and to keep the orphan-specifier cases covered.
Resolve the post-turn hook failures by making the Makefile fall back to the standard user install locations for `cargo` and `markdownlint-cli2` when they are absent from the hook PATH. Remove extra blank lines in the developer guide so `make markdownlint` passes after the rebase.
a20e39c to
163379c
Compare
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 30970
✅ Testing — Resolved
All six required cases are covered. ✅ User-Facing Documentation — Resolved
✅ Developer Documentation — ResolvedThe grammatical corrections were confirmed in the previous round (full file inspection): line 170 reads "a separate line" and line 173 reads "Together, these helpers…" with the required comma. The current output is consistent with those fixes remaining in place. |
Add the blank line required before the CLI matrix harness heading so `make markdownlint` passes after rebasing onto the latest `origin/main`.
Document that `compress_fences` performs conditional compression and preserves outer delimiters when shortening them would change inner fence structure. Clarify that orphan specifier attachment only runs when the specifier line starts a block, so specifiers after prose or other content are left alone.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/fences.rs`:
- Around line 391-433: The inline test module (mod tests) at the bottom of
src/fences.rs pushes the file past the 400-line limit; extract that module into
a new file tests.rs and rewire it as a submodule. Create src/fences/tests.rs
containing the existing test functions
(attach_to_next_fence_attaches_to_unlabelled_fence and
attach_to_next_fence_preserves_specifier_when_no_attachment_occurs) with the
same imports (use super::*; use rstest::rstest;), then in src/fences.rs replace
the inline mod tests { ... } with mod tests; so the tests still reference
FenceTracker and attach_to_next_fence via super. Ensure Cargo test discovery
still runs the moved tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 9976d944-8b20-4365-9276-1344acff0017
📒 Files selected for processing (6)
MakefileREADME.mddocs/developers-guide.mddocs/users-guide.mdsrc/fences.rstests/fences.rs
Split orphan specifier attachment into a private helper module with a pure lookahead step and an explicit `AttachmentOutcome`. This makes the command-side iterator, output, and tracker mutations visible to callers. Move direct helper tests into the private `fences` test module and cover non-empty indentation, mismatched indentation, tracker updates, success, failure, blank-line handling, and iterator exhaustion.
00c991d to
8faa394
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/fences/attachment.rs`:
- Around line 6-10: Add Rustdoc comments to the restricted-public enum
AttachmentOutcome and its variants to document the cross-module API used by
fences.rs and fences/tests.rs: add a top-level /// comment above
AttachmentOutcome describing its role (that it represents the result of an
attachment operation and is visible across modules) and short /// comments for
each variant (Attached — when an item was attached; Preserved — when an existing
attachment was preserved), using /// style Rustdoc so cargo doc can pick it up.
In `@src/fences/tests.rs`:
- Around line 13-17: The tests duplicate initialization of out (Vec<String>) and
tracker (FenceTracker); extract those into rstest fixtures and inject them into
the test functions instead of creating them inline: create fixtures that return
Vec<String> (empty) and FenceTracker::new(), annotate tests (e.g.,
attach_to_next_fence_attaches_to_unlabelled_fence) to accept parameters mut out:
Vec<String> and mut tracker: FenceTracker, remove the local let mut out / let
mut tracker lines, and apply the same fixture-based change to the other tests
that repeat the same setup (the tests around the other similar cases).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6ca47807-3347-4cb4-a33a-fe863bd9ded4
📒 Files selected for processing (3)
src/fences.rssrc/fences/attachment.rssrc/fences/tests.rs
|
@coderabbitai pause |
Add Rustdoc for the cross-module AttachmentOutcome enum and move repeated fence helper test setup into rstest fixtures.
✅ Actions performedReviews paused. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Delete the private `attach_to_next_fence` test module so fence behaviour is exercised through the public `attach_orphan_specifiers` boundary.
This comment was marked as resolved.
This comment was marked as resolved.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 47040
✅ Unit Architecture — Resolved
✅ Testing (Unit) — Resolved
✅ Testing (Overall) — Resolved
✅ User-Facing Documentation — Resolved
❌ Developer Documentation — Not fully resolvedThe ✅ Module-Level Documentation — Resolved
✅ Testing (Compile-Time / UI) — Not applicableThe PR introduces no UI or compile-time test artefacts. The existing |
Summary
Changes
Core Refactor
let mut lines = lines.iter().peekable();Helper
attach_to_next_fenceas a helper to perform the lookahead logicattach_specifier_to_fencehelper for building the final fence lineDocs
attach_to_next_fence, and centralize lookahead logicCleanup
orphan_specifier_targetandorphan_specifier_target_without_languageTests
Behavior
Test plan
📎 Task: https://www.devboxer.com/task/4514e7a4-abf4-4250-a7d4-aed05c8c7898