feat(slides): report resolved table size mismatches#1928
Conversation
📝 WalkthroughWalkthroughThe XML linter now resolves table dimensions, detects canvas overflow and declared-size mismatches, and reports informational issue counts in JSON output. Tests cover table bounds, sizing behavior, and CLI results; table sizing guidance was removed from the format guide. ChangesTable layout validation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant lint_xml
participant lint_slide
participant solve_weighted_min_layout
participant JSONSummary
lint_xml->>lint_slide: slide XML and canvas dimensions
lint_slide->>solve_weighted_min_layout: table column and row sizes
solve_weighted_min_layout-->>lint_slide: resolved sizes and totals
lint_slide-->>lint_xml: table issues
lint_xml->>JSONSummary: aggregate error, warning, and info counts
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 1002-1004: Unify fallback table ID generation between
extract_elements and this table-processing loop so every anonymous table
receives the same identifier regardless of diagnostic type. Reuse shared parsed
table records or a common fallback-ID generator, preserving explicit table IDs
and ensuring anonymous tables are numbered among all elements consistently.
- Around line 940-945: Update the table-processing flow in extract_elements and
the table canvas-validation loop to retain tables even when declared width or
height is missing, resolve one effective bounding box from the table’s columns
and rows, and use that geometry for both table_out_of_canvas overflow checks and
declared-size mismatch checks. Ensure resolved extents beyond the slide produce
table_out_of_canvas rather than only an informational mismatch.
- Around line 101-109: Update fill_last_size_gap so the computed final_sizes[-1]
is never zero or negative, while preserving the target-size sum whenever
possible. Clamp or otherwise redistribute sizes so inputs such as empty columns
resolving to a 1px target cannot produce [1, 0], and ensure the resulting
dimensions remain valid for the existing mismatch 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 12e0fb3a-5788-4236-8bc2-dc6bfc68d020
📒 Files selected for processing (3)
skills/lark-slides/references/xml-format-guide.mdskills/lark-slides/scripts/xml_text_overlap_lint.pyskills/lark-slides/scripts/xml_text_overlap_lint_test.py
💤 Files with no reviewable changes (1)
- skills/lark-slides/references/xml-format-guide.md
🚀 PR Preview Install Guide🧰 CLI updatenpm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@ab27e2bf8c16af9db607ab1cb6cf6aed802a96b0🧩 Skill updatenpx skills add larksuite/cli#feat/slides_table_lint -y -g |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1928 +/- ##
=======================================
Coverage 74.96% 74.96%
=======================================
Files 892 892
Lines 94058 94077 +19
=======================================
+ Hits 70506 70529 +23
+ Misses 18139 18137 -2
+ Partials 5413 5411 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
8356b2a to
ab27e2b
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
skills/lark-slides/scripts/xml_text_overlap_lint_test.py (1)
977-978: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the return code before parsing stdout.
If the subprocess crashes (e.g., due to a syntax error or a missing import),
stdoutwill likely be empty. Attempting to parse it first will raise aJSONDecodeError, burying the actual crash details fromstderr. Swapping these two lines ensures that if the process fails, the test reports the actual error fromcompleted.stderr.♻️ Proposed refactor
- result = json.loads(completed.stdout) - self.assertEqual(completed.returncode, 0, completed.stderr) + self.assertEqual(completed.returncode, 0, completed.stderr) + result = json.loads(completed.stdout)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py` around lines 977 - 978, In the subprocess test around completed, move the assertEqual check for completed.returncode before json.loads(completed.stdout). Preserve the existing stderr failure detail so subprocess errors are reported directly instead of being masked by JSON parsing.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint.py`:
- Around line 1012-1014: Bound the `<col span>` value in the column-size
expansion logic before `sizes.extend` allocates entries. Define or reuse the
table-column limit, validate `span_count` against it, and emit the existing lint
error through the surrounding lint-reporting path before allocation; preserve
normal expansion for valid spans.
- Around line 598-601: Update the element-content extraction in the shape/table
matching logic to detect when the matched opening element is self-closing and
skip searching for a closing tag in that case. Ensure self-closing tables
receive empty content, while non-self-closing elements continue using their
matching closing tag and do not consume sibling content.
---
Nitpick comments:
In `@skills/lark-slides/scripts/xml_text_overlap_lint_test.py`:
- Around line 977-978: In the subprocess test around completed, move the
assertEqual check for completed.returncode before json.loads(completed.stdout).
Preserve the existing stderr failure detail so subprocess errors are reported
directly instead of being masked by JSON parsing.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: dc1cee95-08c1-4852-84e4-36a1f0d58a11
📒 Files selected for processing (3)
skills/lark-slides/references/xml-format-guide.mdskills/lark-slides/scripts/xml_text_overlap_lint.pyskills/lark-slides/scripts/xml_text_overlap_lint_test.py
💤 Files with no reviewable changes (1)
- skills/lark-slides/references/xml-format-guide.md
|
Thanks for the table-geometry lint improvements. I verified the current PR head (
Separately, my read of the new sizing behavior is: table width/height are treated as target minimum dimensions; filled column/row sizes are preserved; empty columns/rows share remaining space; when all child sizes are filled and the target is larger, sizes are scaled by their existing weights; when the target is too small, filled sizes/defaults win and the resolved total can exceed the declared table size. The resolved bbox is then used for |
Summary
Improve the Slides XML lint for table geometry. It detects table bounds outside the canvas and reports informational size mismatches when the renderer's resolved row or column totals differ from the declared table dimensions.
Changes
infooutput for weighted row and column layout resolution mismatches, including resolved dimensions and correction guidance.Test Plan
python3 -m unittest xml_text_overlap_lint_test(42 tests)Related Issues
Summary by CodeRabbit