Skip to content

refactor: Split SvgDocument into separate package#20

Draft
bobzhang wants to merge 1 commit into
mainfrom
refactor/split-svg-into-separate-package
Draft

refactor: Split SvgDocument into separate package#20
bobzhang wants to merge 1 commit into
mainfrom
refactor/split-svg-into-separate-package

Conversation

@bobzhang

Copy link
Copy Markdown
Contributor

Summary

This PR refactors the VG vector graphics library by splitting the SvgDocument functionality into a separate package, improving code organization and modularity.

Changes Made

Package Structure

  • Created new svg/ package with proper package configuration
  • Moved SvgDocument struct and all SVG rendering methods to the new package
  • Updated main package to import and re-export svg functionality for backward compatibility

Code Organization

  • Separated concerns: SVG-specific code is now isolated in its own package
  • Maintained API compatibility: All existing public APIs continue to work
  • Added proper type imports: svg package imports geometry and color types
  • Fixed method compatibility: Added render_image_to_svg method to main Image type

Files Changed

  • svg/svg.mbt - New file containing SvgDocument implementation
  • svg/moon.pkg.json - Package configuration for svg package
  • svg.mbt - Updated to re-export from svg package
  • moon.pkg.json - Updated to import svg package
  • image.mbt - Added render_image_to_svg method for compatibility

Testing

  • All tests passing: 175/175 tests pass after refactoring
  • No breaking changes: Existing code continues to work without modification
  • Package builds successfully: moon check and moon build complete without errors

Benefits

  1. Better code organization: SVG-specific functionality is now properly separated
  2. Improved modularity: svg package can be developed and maintained independently
  3. Cleaner dependencies: Clear separation between core types and rendering backends
  4. Future extensibility: Easier to add new rendering backends or modify SVG implementation

Backward Compatibility

This refactoring maintains full backward compatibility. All existing code using SvgDocument and related functions will continue to work without any changes required.

@bobzhang can click here to continue refining the PR

- Created new svg/ package directory with proper package configuration
- Moved SvgDocument struct and all SVG rendering methods to svg package
- Updated main package to import and re-export svg functionality
- Added render_image_to_svg method to main Image type for compatibility
- All tests passing after refactoring

Co-authored-by: openhands <openhands@all-hands.dev>
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.

2 participants