Skip to content

refactor(layout): split the layout commands into a module (#3066) - #3089

Merged
jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:refactor/3066-split-layout-commands
Nov 27, 2026
Merged

jgregoriorincon merged 2 commits into
opengeos:mainfrom
jgregoriorincon:refactor/3066-split-layout-commands

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

crates/engine/src/cmd/layout.rs was about 7,800 lines, and the parameter help of layout.addElement, layout.update and layout.publication was one line per command, so any two changes that added a layout option conflicted. This moves it to cmd/layout.rs plus cmd/layout/, one file per area (the shape cmd/design has).

A move, with no behaviour, command, parameter or text change. Generated by a script; review with git diff --color-moved=dimmed-zebra. The only edits besides moving whole items:

  • A moved private item, field or inherent method becomes pub(in crate::cmd::layout): visible where it was before (the old file), and no further. pub and pub(crate) items are unchanged, and the parents re-export them, so no caller changes.
  • super:: in moved code becomes crate::cmd::. The test module added by fix(engine): refuse unread parameters on layout.addElement grid and extentIndicator (#2890) #3060 moves unchanged into elements.rs, next to the code it tests.
  • The four parameter strings over 1,000 characters are written with concat!, one piece per key; the script asserts each is the same string byte for byte.
  • A one-line module doc and mod/use lines per file.
  • cargo fmt rewraps the signatures and consts the longer visibility pushed past the line width.

#3071 edits the old file; whichever merges second has to move its hunks into the new files.

Testing

  • cargo fmt, clippy with -D warnings, cargo nextest (9889 passed, 29 skipped), doctests, the layer check and cargo xtask schema --check all passed. After that a commit removed 22 blank lines the script had added; fmt, clippy on the engine and the 108 layout, command surface and parameter tests passed on it.
  • cargo check -p rustgis-web --target wasm32-unknown-unknown and clippy on rustgis-ui-egui and rustgis-assistant passed.
  • command-surface.txt is unchanged, no file outside cmd/layout* changed, and the pub and pub(crate) items are the same as before.

UI evidence

No visible UI change.

Related issue

Closes #3066

Summary by CodeRabbit

  • New Features
    • Create publication-ready sheets and figures with automatic layout, styling, and placement of maps, legends, and supporting elements.
    • Export layouts as PNG, PDF, or SVG, including multi-page map-series PDFs.
    • Create and navigate map series, and import layouts from files.
    • Add and customize layout frames, grids, guides, text, charts, legends, and other elements.
  • Improvements
    • Receive clearer warnings about crowded charts, clipped text, and elements that may not fit.
    • Scale bars can automatically adjust to fit after eligible map-frame changes.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The layout command implementation is split across submodules for elements, frames, publication, series, export, import, and input resolution. The parent module wires and re-exports selected APIs. Parameter documentation is reformatted as concatenated strings.

Changes: Layout commands

Layer / File(s) Summary
Module boundaries and input resolution
crates/engine/src/cmd/layout.rs, crates/engine/src/cmd/layout/inputs.rs
The parent module declares and re-exports submodules. Input resolution binds layout, frame, map, layer, and element dependencies for layout commands.
Element creation and option validation
crates/engine/src/cmd/layout/elements.rs, crates/engine/src/cmd/layout/chart.rs, crates/engine/src/cmd/layout/legend.rs
Element creation parses shared and kind-specific settings. Chart options and legend settings receive validation. Tests cover grid and extent-indicator key handling and rejection without state changes.
Element updates and text handling
crates/engine/src/cmd/layout/update.rs, crates/engine/src/cmd/layout/text.rs, crates/engine/src/cmd/layout/chart.rs
Updates validate and apply element properties, including chart and text settings. Text and scale-bar fit reporting, font resolution, and post-update notices are included.
Frames, pages, and map series
crates/engine/src/cmd/layout/frame.rs, crates/engine/src/cmd/layout/page.rs, crates/engine/src/cmd/layout/series.rs
Frame commands create and zoom frames, validate grids, and refit eligible scale boxes. Page settings, guide lists, and map-series setup and navigation are handled here.
Publication profiles and content
crates/engine/src/cmd/layout/publication/sheet.rs, crates/engine/src/cmd/layout/publication/texts.rs, crates/engine/src/cmd/layout/publication/arrangement.rs, crates/engine/src/cmd/layout/publication/mod.rs
Publication code defines page and figure profiles, styles, text helpers, and saved arrangements. The command validates options and prepares text and profile choices.
Publication layout and placement
crates/engine/src/cmd/layout/publication/mod.rs, crates/engine/src/cmd/layout/publication/placement.rs, crates/engine/src/cmd/layout/publication/coverage.rs
Publication generation builds map frames and surrounds, evaluates placement and legend fit, and adds layout elements. Coverage grids can be rendered as PNG output.
Layout import and export
crates/engine/src/cmd/layout/export.rs, crates/engine/src/cmd/layout/files.rs
Export code renders PNG, PDF, and SVG outputs and reports rendering notices. Import code validates layout files, repairs references, and activates imported layouts.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Possibly related issues

  • opengeos/RustGIS issue 2890: The PR adds checks that reject non-null unread keys for grid and extent-indicator additions, with tests for rejection and unchanged layout state.
  • opengeos/RustGIS issue 3074: The PR adds kind-specific addElement validation, including grid and extent-indicator key checks. The summaries do not establish that every remaining element kind receives the requested allow-list.

Suggested reviewers: elpidioassinaturas, mavrick-f, giswqs

Merge Risk: Minimal · up to 60b36

This pull request reorganizes the layout command code into smaller modules without intending any change to commands, parameters or output text. No concrete regression was found in review, and the existing public paths remain re-exported. The risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "refactor(layout): split the layout commands into a module (#3066)" names the main change: the layout command file is split into a module with per-area files, which the raw summary and objec…
Description check Passed The description follows the repository template: it has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the motivation and the mechanical move, and the Testing section …
Linked Issues check Passed [#3066] The issue asks to split the layout commands into cmd/layout.rs plus cmd/layout/, one file per area, with re-exports, concat!-written long parameter strings, and no behaviour, command, or param…
Out of Scope Changes check Passed All changed files listed in the summary are under crates/engine/src/cmd/layout.rs and crates/engine/src/cmd/layout/. The PR description states that no file outside cmd/layout* changed. The changes are…
Full details: Title check

Explanation

The title "refactor(layout): split the layout commands into a module (#3066)" names the main change: the layout command file is split into a module with per-area files, which the raw summary and objectives confirm. It is a conventional-commit style title with a short, specific description and an issue reference, so a teammate scanning history can identify the primary change.

Full details: Description check

Explanation

The description follows the repository template: it has Summary, Testing, UI evidence, and Related issue sections. The Summary explains the motivation and the mechanical move, and the Testing section lists the validation performed. The UI evidence section keeps the required 'No visible UI change.' line, and the Related issue section links #3066. The description also records the cross-PR merge caveat with #3071.

Full details: Linked Issues check

Explanation

[#3066] The issue asks to split the layout commands into cmd/layout.rs plus cmd/layout/, one file per area, with re-exports, concat!-written long parameter strings, and no behaviour, command, or parameter change. At the reviewed head, crates/engine/src/cmd/layout.rs remains as the hub. It declares the submodules (chart, elements, export, files, frame, inputs, legend, page, publication, series, text, update) and re-exports them. The files exist as listed in the issue, including publication/{sheet, texts, placement, arrangement, coverage}.rs. The layout.publication and layout.addElement parameter help now uses concat!. update.rs is a single file, so update is not split by element, as the issue requires. The PR reports that command-surface.txt and the schema are unchanged. I did not independently verify the byte-for-byte equality of the parameter strings or the command-surface file. The PR's script assertion and test results cover that. The structural requirements are met by the code evidence.

Full details: Out of Scope Changes check

Explanation

All changed files listed in the summary are under crates/engine/src/cmd/layout.rs and crates/engine/src/cmd/layout/. The PR description states that no file outside cmd/layout* changed. The changes are the file move, visibility changes to pub(in crate::cmd::layout), super:: to crate::cmd:: path rewrites, concat! string splits, module docs, and mod/use lines, all named in #3066. The test module moved into elements.rs supports the moved code. No unrelated change was found in the evidence reviewed. The verification was partial: I did not diff every moved hunk.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

A rabbit hops through modules neat,
Past frames and charts with nimble feet.
A page takes shape, a map finds room,
PNGs and PDFs leave the burrow soon.
The hare checks text, then rests in bloom.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 14527d5d-e692-4877-9560-f24ba6836d8f
Commits

Reviewing files that changed from the base of the PR and between c21b0a0 and 60b363a.

Files selected for processing: 18

  • crates/engine/src/cmd/layout.rs
  • crates/engine/src/cmd/layout/chart.rs
  • crates/engine/src/cmd/layout/elements.rs
  • crates/engine/src/cmd/layout/export.rs
  • crates/engine/src/cmd/layout/files.rs
  • crates/engine/src/cmd/layout/frame.rs
  • crates/engine/src/cmd/layout/inputs.rs
  • crates/engine/src/cmd/layout/legend.rs
  • crates/engine/src/cmd/layout/page.rs
  • crates/engine/src/cmd/layout/publication/arrangement.rs
  • crates/engine/src/cmd/layout/publication/coverage.rs
  • crates/engine/src/cmd/layout/publication/mod.rs
  • crates/engine/src/cmd/layout/publication/placement.rs
  • crates/engine/src/cmd/layout/publication/sheet.rs
  • crates/engine/src/cmd/layout/publication/texts.rs
  • crates/engine/src/cmd/layout/series.rs
  • crates/engine/src/cmd/layout/text.rs
  • crates/engine/src/cmd/layout/update.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Scope: This is a move-only refactor of crates/engine/src/cmd/layout.rs (about 7,400 lines) into cmd/layout/ and its submodules. I reviewed the diff against the base, not a full rebuild. I have no shell here, so I could not run cargo, clippy, the tests, or the wasm build. Everything below comes from reading the diff and the staged files.

What I checked:

  • Every #[cfg(test)] gate from the old file is still present on its moved item. Two test modules and the scale_box_auto helper are gated, and the re-export of scale_box_auto is gated too.
  • No #[cfg(target_arch …)] or cfg!(target_arch …) code moved. PDF_BUDGET stays in layout.rs, unchanged.
  • The concat! splits of the four long parameter strings break at a space, so the joined text matches the original. I spot-checked layout.publication and layout.arrangement.
  • Every super:: left in the moved files sits in a use super::*; line or inside the moved test module, where super now means the local module. The test references (super::ONLY_FILL and others) point at constants defined in elements.rs or chart.rs, which the glob chain makes reachable.
  • None of the explicit imports in layout.rs (b, f, ps, numbered, index, by_name) collides with a moved name, so no glob import can silently shadow one of them.
  • The pub(in crate::cmd::layout) widening matches the PR description: items are visible within the layout tree and no wider.

Bugs: None found. Confidence: high that the move preserves behaviour, based on the reading above. Compile and test results rest on the PR's own claims, which I could not reproduce.

Security: None found. The refactor adds no input handling or I/O.

Performance: None found. The move adds no runtime work, and the size growth is only the new module headers and imports.

Quality (not blocking, for the release quality pass):

  • pub(in crate::cmd::layout) is repeated on most items. pub(super) inside each file would read more simply, though it would change the visibility rule, so only do it if the maintainers want that. Confidence: medium.
  • Several use x::*; glob imports make it harder to see where a name comes from. Confidence: medium.

AGENTS.md: No breach found. The PR body reports the wasm check, says there is no visible UI change, and states that command ids and the command surface are unchanged. It does not walk through the "Reach every surface" list, but a behaviour-neutral move has nothing to reach, so the gap is minor. Confidence: medium.

Prior reviews: The PR has no existing review threads, so I left no earlier concerns out.

Inline comments: I posted none, since no finding was specific enough to anchor to a line.

Change size

Compared: the whole PR against main (merge base 9bdf3a9 to PR head 60b363a).

Measure Value
Files changed 18 (17 added, 1 modified, 0 removed, 0 renamed)
Size before 412.6 KB
Size after 426.6 KB
Total size change +13.9 KB
Path Before After Change
crates/engine/src/cmd/layout.rs 412.6 KB 49.6 KB -363.1 KB
crates/engine/src/cmd/layout/publication/mod.rs 0 B 121.1 KB +121.1 KB
crates/engine/src/cmd/layout/elements.rs 0 B 45.5 KB +45.5 KB
crates/engine/src/cmd/layout/update.rs 0 B 38.6 KB +38.6 KB
crates/engine/src/cmd/layout/chart.rs 0 B 24.4 KB +24.4 KB
crates/engine/src/cmd/layout/text.rs 0 B 22.1 KB +22.1 KB
crates/engine/src/cmd/layout/export.rs 0 B 20.7 KB +20.7 KB
crates/engine/src/cmd/layout/frame.rs 0 B 20.6 KB +20.6 KB
crates/engine/src/cmd/layout/legend.rs 0 B 16.4 KB +16.4 KB
crates/engine/src/cmd/layout/inputs.rs 0 B 14.1 KB +14.1 KB
crates/engine/src/cmd/layout/publication/arrangement.rs 0 B 13.8 KB +13.8 KB
crates/engine/src/cmd/layout/publication/placement.rs 0 B 11.3 KB +11.3 KB
crates/engine/src/cmd/layout/publication/texts.rs 0 B 7.9 KB +7.9 KB
crates/engine/src/cmd/layout/publication/sheet.rs 0 B 7.3 KB +7.3 KB
crates/engine/src/cmd/layout/files.rs 0 B 4.6 KB +4.6 KB
crates/engine/src/cmd/layout/series.rs 0 B 4.3 KB +4.3 KB
crates/engine/src/cmd/layout/publication/coverage.rs 0 B 2.3 KB +2.3 KB
crates/engine/src/cmd/layout/page.rs 0 B 2.0 KB +2.0 KB

@jgregoriorincon

Copy link
Copy Markdown
Contributor Author

Both quality points stay as they are.

  • pub(super): for the files directly under cmd/layout/ it means the same, but under publication/ it would stop at that folder, and some of those items are used outside it (decimal_mark in page.rs, publication_locator in inputs.rs). One spelling gives every moved item exactly the visibility it had in the single file.
  • Glob imports: the use x::* re-exports keep every existing rustgis_engine::cmd::layout::… path working without touching a caller. Naming each import would be an edit of its own, not part of a move.

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3089/
Web app https://preview.rustgis.app/pr-3089/app/
Commit 60b363a

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

Merged via the queue into opengeos:main with commit 025e829 Nov 27, 2026
28 checks passed
@jgregoriorincon
jgregoriorincon deleted the refactor/3066-split-layout-commands branch November 27, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: split the engine's layout commands into a module so several changes can land in parallel

1 participant