SVG2DrawIOLib 1.2.0__tar.gz → 1.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/ARCHITECTURE.md +217 -30
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/CHANGELOG.md +23 -0
- svg2drawiolib-1.2.1/CONTRIBUTING.md +467 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/LICENSE.txt +1 -1
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/PKG-INFO +159 -10
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/QUICKSTART.md +163 -8
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/README.md +158 -9
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/__about__.py +1 -1
- svg2drawiolib-1.2.0/CONTRIBUTING.md +0 -248
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/.github/workflows/ci.yml +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/.github/workflows/publish.yml +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/.github/workflows/release.yml +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/.gitignore +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/.pre-commit-config.yaml +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/MANIFEST.in +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/Makefile +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/pyproject.toml +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/__init__.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/__init__.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/add.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/create.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/create_helpers.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/extract.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/helpers.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/inspect.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/list.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/remove.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/rename.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/split_paths.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/cli/validate.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/icon_analyzer.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/library_manager.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/models.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/path_splitter.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/svg_processor.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/src/SVG2DrawIOLib/validator.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/__init__.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/conftest.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_create_helpers.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_create_split.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_extract.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_helpers.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_inspect.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_rename.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_cli_validate.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_css_modes.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_library_manager.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_models.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_path_splitter.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_svg_processor.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_svg_processor_coverage.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/tests/test_viewbox_improvements.py +0 -0
- {svg2drawiolib-1.2.0 → svg2drawiolib-1.2.1}/uv.lock +0 -0
|
@@ -18,7 +18,7 @@ This document describes the modular architecture of SVG2DrawIOLib.
|
|
|
18
18
|
### 3. Testability
|
|
19
19
|
- Dependency injection
|
|
20
20
|
- Clear interfaces
|
|
21
|
-
-
|
|
21
|
+
- 94% test coverage (421 tests)
|
|
22
22
|
|
|
23
23
|
## Module Structure
|
|
24
24
|
|
|
@@ -29,13 +29,22 @@ src/SVG2DrawIOLib/
|
|
|
29
29
|
├── models.py # Data models (dataclasses)
|
|
30
30
|
├── svg_processor.py # SVG processing logic
|
|
31
31
|
├── library_manager.py # Library file management
|
|
32
|
+
├── icon_analyzer.py # Icon extraction and analysis service
|
|
33
|
+
├── library_validator.py # Library validation service
|
|
34
|
+
├── path_splitter.py # SVG path splitting logic
|
|
32
35
|
└── cli/ # Modular CLI with dynamic loading
|
|
33
36
|
├── __init__.py # CLI entry point with dynamic command discovery
|
|
34
37
|
├── helpers.py # Shared CLI utilities
|
|
35
38
|
├── create.py # Create command
|
|
39
|
+
├── create_helpers.py # Business logic for create command
|
|
36
40
|
├── add.py # Add command
|
|
37
41
|
├── remove.py # Remove command
|
|
38
|
-
|
|
42
|
+
├── list.py # List command
|
|
43
|
+
├── extract.py # Extract command
|
|
44
|
+
├── rename.py # Rename command
|
|
45
|
+
├── inspect.py # Inspect command
|
|
46
|
+
├── validate.py # Validate command
|
|
47
|
+
└── split_paths.py # Split paths command
|
|
39
48
|
```
|
|
40
49
|
|
|
41
50
|
## Core Components
|
|
@@ -83,7 +92,10 @@ Configuration for SVG processing.
|
|
|
83
92
|
@dataclass
|
|
84
93
|
class SVGProcessingOptions:
|
|
85
94
|
add_css: bool = False
|
|
95
|
+
css_mode: str = "fill" # "fill", "stroke", or "both"
|
|
86
96
|
css_color: str = "#000000"
|
|
97
|
+
css_stroke_color: str = "#000000"
|
|
98
|
+
preserve_current_color: bool = True
|
|
87
99
|
xml_namespace: str = "http://www.w3.org/2000/svg"
|
|
88
100
|
css_tag: str = "path"
|
|
89
101
|
|
|
@@ -91,6 +103,11 @@ class SVGProcessingOptions:
|
|
|
91
103
|
def namespaced_tag(self) -> str
|
|
92
104
|
```
|
|
93
105
|
|
|
106
|
+
**CSS Modes:**
|
|
107
|
+
- `fill`: Generate CSS rules for fill colors only (default)
|
|
108
|
+
- `stroke`: Generate CSS rules for stroke colors only
|
|
109
|
+
- `both`: Generate CSS rules for both fill and stroke colors
|
|
110
|
+
|
|
94
111
|
#### LibraryMetadata
|
|
95
112
|
Metadata about a DrawIO library.
|
|
96
113
|
|
|
@@ -114,6 +131,7 @@ class SVGProcessor:
|
|
|
114
131
|
def add_css_classes(self, svg_tree: ET.ElementTree) -> ET.ElementTree
|
|
115
132
|
def get_svg_dimensions(self, svg_tree: ET.ElementTree) -> tuple[float, float] | None
|
|
116
133
|
def calculate_dimensions(self, svg_tree: ET.ElementTree, max_dimension: float | None) -> SVGDimensions
|
|
134
|
+
def adjust_svg_viewbox_to_content(self, svg_tree: ET.ElementTree) -> ET.ElementTree
|
|
117
135
|
def svg_to_data_uri(self, svg_tree: ET.ElementTree) -> str
|
|
118
136
|
def process_svg_file(self, filepath: Path, max_dimension: float | None) -> DrawIOIcon
|
|
119
137
|
```
|
|
@@ -121,7 +139,12 @@ class SVGProcessor:
|
|
|
121
139
|
**Key Features:**
|
|
122
140
|
- Automatic dimension extraction from SVG
|
|
123
141
|
- Proportional scaling support
|
|
124
|
-
- CSS class injection
|
|
142
|
+
- CSS class injection with multiple modes (fill, stroke, both)
|
|
143
|
+
- Style attribute parsing (`style="fill:#fff;stroke:#000"`)
|
|
144
|
+
- Special value handling (`fill="none"`, `stroke="none"`, `currentColor`)
|
|
145
|
+
- ViewBox adjustment with svgelements integration for accurate bounds
|
|
146
|
+
- Transform handling (translate, scale, rotate, skew, matrix)
|
|
147
|
+
- Non-rendering container exclusion (defs, clipPath, mask, symbol, pattern, marker)
|
|
125
148
|
- Data URI generation
|
|
126
149
|
- mxGraphModel creation
|
|
127
150
|
- Compression and encoding
|
|
@@ -132,10 +155,11 @@ Manages DrawIO library files.
|
|
|
132
155
|
|
|
133
156
|
```python
|
|
134
157
|
class LibraryManager:
|
|
135
|
-
def create_library(self, icons: list[DrawIOIcon], output_path: Path) -> LibraryMetadata
|
|
136
|
-
def load_library(self, library_path: Path) ->
|
|
137
|
-
def add_icons_to_library(self, library_path: Path, new_icons: list[DrawIOIcon], replace_duplicates: bool) -> LibraryMetadata
|
|
158
|
+
def create_library(self, icons: list[DrawIOIcon], output_path: Path, source_files: list[Path] | None) -> LibraryMetadata
|
|
159
|
+
def load_library(self, library_path: Path) -> LibraryMetadata
|
|
160
|
+
def add_icons_to_library(self, library_path: Path, new_icons: list[DrawIOIcon], replace_duplicates: bool, source_files: list[Path] | None) -> LibraryMetadata
|
|
138
161
|
def remove_icons_from_library(self, library_path: Path, icon_names: list[str]) -> LibraryMetadata
|
|
162
|
+
def rename_icon(self, library_path: Path, old_name: str, new_name: str, overwrite: bool) -> LibraryMetadata
|
|
139
163
|
def list_icons(self, library_path: Path) -> list[str]
|
|
140
164
|
```
|
|
141
165
|
|
|
@@ -144,10 +168,67 @@ class LibraryManager:
|
|
|
144
168
|
- Load existing libraries
|
|
145
169
|
- Add icons (with duplicate handling)
|
|
146
170
|
- Remove icons by name
|
|
171
|
+
- Rename icons within library
|
|
147
172
|
- List all icons
|
|
148
173
|
- Automatic alphabetical sorting
|
|
174
|
+
- Source file tracking
|
|
175
|
+
|
|
176
|
+
### 4. Icon Analyzer (`icon_analyzer.py`)
|
|
177
|
+
|
|
178
|
+
Service for extracting and analyzing icon content from libraries.
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
class IconAnalyzer:
|
|
182
|
+
def extract_icons(self, library_path: Path, icon_names: list[str] | None) -> list[dict[str, Any]]
|
|
183
|
+
def save_icon_svg(self, icon_data: dict[str, Any], output_dir: Path, overwrite: bool) -> Path
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Key Features:**
|
|
187
|
+
- Extract icon data from libraries
|
|
188
|
+
- Decode and decompress mxGraphModel XML
|
|
189
|
+
- Parse SVG content from data URIs
|
|
190
|
+
- Analyze CSS classes and inline styles
|
|
191
|
+
- Detect shape types (image, embedded SVG, etc.)
|
|
192
|
+
- Save icons back to SVG files
|
|
193
|
+
- Overwrite protection
|
|
194
|
+
|
|
195
|
+
### 5. Library Validator (`library_validator.py`)
|
|
196
|
+
|
|
197
|
+
Service for comprehensive library validation.
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
class LibraryValidator:
|
|
201
|
+
def validate_library(self, library_path: Path) -> dict[str, Any]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Validation Checks:**
|
|
205
|
+
- XML structure validation
|
|
206
|
+
- JSON format validation
|
|
207
|
+
- Icon integrity (required fields, dimensions, encoding)
|
|
208
|
+
- Base64 encoding validation
|
|
209
|
+
- Compression validation
|
|
210
|
+
- mxGraphModel structure validation
|
|
211
|
+
- SVG content validation (namespace, viewBox, empty detection)
|
|
212
|
+
- Detailed error and warning messages
|
|
213
|
+
|
|
214
|
+
### 6. Path Splitter (`path_splitter.py`)
|
|
215
|
+
|
|
216
|
+
Handles splitting compound SVG paths into separate elements.
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
class PathSplitter:
|
|
220
|
+
def split_svg_paths(self, svg_path: Path, output_path: Path) -> dict[str, int]
|
|
221
|
+
```
|
|
149
222
|
|
|
150
|
-
|
|
223
|
+
**Key Features:**
|
|
224
|
+
- Detect compound paths (multiple M/m commands)
|
|
225
|
+
- Split into separate path elements
|
|
226
|
+
- Preserve "donut holes" via bounding box containment detection
|
|
227
|
+
- Generate unique CSS classes for split paths
|
|
228
|
+
- Maintain original path attributes
|
|
229
|
+
- Handle ID collision prevention
|
|
230
|
+
|
|
231
|
+
### 7. CLI (`cli/`)
|
|
151
232
|
|
|
152
233
|
Modular command-line interface with dynamic command loading.
|
|
153
234
|
|
|
@@ -168,11 +249,22 @@ for filepath in COMMAND_DIR.iterdir():
|
|
|
168
249
|
|
|
169
250
|
**Commands:**
|
|
170
251
|
- `cli/create.py` - Create new library
|
|
252
|
+
- `cli/create_helpers.py` - Business logic for create command
|
|
171
253
|
- `cli/add.py` - Add icons to library
|
|
172
254
|
- `cli/remove.py` - Remove icons from library
|
|
173
255
|
- `cli/list.py` - List icons in library
|
|
256
|
+
- `cli/extract.py` - Extract icons to SVG files
|
|
257
|
+
- `cli/rename.py` - Rename icons in library
|
|
258
|
+
- `cli/inspect.py` - Display detailed icon information
|
|
259
|
+
- `cli/validate.py` - Validate library integrity
|
|
260
|
+
- `cli/split_paths.py` - Split compound SVG paths
|
|
174
261
|
- `cli/helpers.py` - Shared utilities (console, setup_logging)
|
|
175
262
|
|
|
263
|
+
**Command Groups:**
|
|
264
|
+
- **Library Management**: create, add, remove, extract, rename
|
|
265
|
+
- **Library Inspection**: list, inspect, validate
|
|
266
|
+
- **SVG Processing**: split-paths
|
|
267
|
+
|
|
176
268
|
**Key Features:**
|
|
177
269
|
- Automatic command discovery
|
|
178
270
|
- Each command in separate file
|
|
@@ -182,7 +274,9 @@ for filepath in COMMAND_DIR.iterdir():
|
|
|
182
274
|
|
|
183
275
|
## CLI Commands
|
|
184
276
|
|
|
185
|
-
###
|
|
277
|
+
### Library Management Commands
|
|
278
|
+
|
|
279
|
+
#### create
|
|
186
280
|
Create a new DrawIO library from SVG files.
|
|
187
281
|
|
|
188
282
|
```bash
|
|
@@ -194,13 +288,18 @@ SVG2DrawIOLib create icons/*.svg -o library.xml [OPTIONS]
|
|
|
194
288
|
- `--width, -w`: Fixed width (overrides max-size)
|
|
195
289
|
- `--height, -h`: Fixed height (overrides max-size)
|
|
196
290
|
- `--css, -c`: Enable color editing
|
|
291
|
+
- `--css-mode`: CSS mode (fill, stroke, both)
|
|
197
292
|
- `--css-color`: CSS fill color
|
|
293
|
+
- `--css-stroke-color`: CSS stroke color
|
|
294
|
+
- `--preserve-current-color/--no-preserve-current-color`: Preserve currentColor values
|
|
198
295
|
- `--namespace, -n`: XML namespace
|
|
199
|
-
- `--tag, -t`:
|
|
296
|
+
- `--tag, -t`: SVG element type to target for CSS classes
|
|
297
|
+
- `--recursive, -R`: Recursively search directories
|
|
298
|
+
- `--split-by-folder, -S`: Create separate libraries per subdirectory
|
|
200
299
|
- `--verbose, -v`: Debug logging
|
|
201
300
|
- `--quiet, -q`: Suppress output
|
|
202
301
|
|
|
203
|
-
|
|
302
|
+
#### add
|
|
204
303
|
Add SVG icons to an existing library.
|
|
205
304
|
|
|
206
305
|
```bash
|
|
@@ -209,12 +308,15 @@ SVG2DrawIOLib add library.xml new-icon.svg [OPTIONS]
|
|
|
209
308
|
|
|
210
309
|
**Options:**
|
|
211
310
|
- `--replace, -r`: Replace duplicates
|
|
311
|
+
- `--add-dupes, -d`: Add duplicates with modified names
|
|
212
312
|
- `--max-size, -s`: Scale new icons
|
|
213
313
|
- `--css, -c`: Enable color editing
|
|
314
|
+
- `--css-mode`: CSS mode (fill, stroke, both)
|
|
315
|
+
- `--recursive, -R`: Recursively search directories
|
|
214
316
|
- `--verbose, -v`: Debug logging
|
|
215
317
|
- `--quiet, -q`: Suppress output
|
|
216
318
|
|
|
217
|
-
|
|
319
|
+
#### remove
|
|
218
320
|
Remove icons from a library by name.
|
|
219
321
|
|
|
220
322
|
```bash
|
|
@@ -225,7 +327,37 @@ SVG2DrawIOLib remove library.xml icon1 icon2 [OPTIONS]
|
|
|
225
327
|
- `--verbose, -v`: Debug logging
|
|
226
328
|
- `--quiet, -q`: Suppress output
|
|
227
329
|
|
|
228
|
-
|
|
330
|
+
#### extract
|
|
331
|
+
Extract icons from a library back to individual SVG files.
|
|
332
|
+
|
|
333
|
+
```bash
|
|
334
|
+
SVG2DrawIOLib extract library.xml -o output-dir/ [OPTIONS]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Options:**
|
|
338
|
+
- `--output-dir, -o`: Output directory (required)
|
|
339
|
+
- `--icons, -i`: Specific icon names to extract
|
|
340
|
+
- `--overwrite`: Overwrite existing files
|
|
341
|
+
- `--verbose, -v`: Debug logging
|
|
342
|
+
- `--quiet, -q`: Suppress output
|
|
343
|
+
|
|
344
|
+
#### rename
|
|
345
|
+
Rename an icon within a library.
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
SVG2DrawIOLib rename library.xml -o old-name -n new-name [OPTIONS]
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
**Options:**
|
|
352
|
+
- `--old-name, -o`: Current icon name (required)
|
|
353
|
+
- `--new-name, -n`: New icon name (required)
|
|
354
|
+
- `--overwrite`: Overwrite if new name exists
|
|
355
|
+
- `--verbose, -v`: Debug logging
|
|
356
|
+
- `--quiet, -q`: Suppress output
|
|
357
|
+
|
|
358
|
+
### Library Inspection Commands
|
|
359
|
+
|
|
360
|
+
#### list
|
|
229
361
|
List all icons in a library.
|
|
230
362
|
|
|
231
363
|
```bash
|
|
@@ -236,6 +368,44 @@ SVG2DrawIOLib list library.xml [OPTIONS]
|
|
|
236
368
|
- `--verbose, -v`: Debug logging
|
|
237
369
|
- `--quiet, -q`: Suppress output
|
|
238
370
|
|
|
371
|
+
#### inspect
|
|
372
|
+
Display detailed information about icons in a library.
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
SVG2DrawIOLib inspect library.xml [ICON_NAMES]... [OPTIONS]
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
**Options:**
|
|
379
|
+
- `--show-svg`: Display decoded SVG content
|
|
380
|
+
- `--json`: Output in JSON format
|
|
381
|
+
- `--verbose, -v`: Debug logging
|
|
382
|
+
- `--quiet, -q`: Suppress output
|
|
383
|
+
|
|
384
|
+
#### validate
|
|
385
|
+
Validate DrawIO library file integrity.
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
SVG2DrawIOLib validate library.xml [OPTIONS]
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Options:**
|
|
392
|
+
- `--verbose, -v`: Debug logging
|
|
393
|
+
- `--quiet, -q`: Suppress output
|
|
394
|
+
|
|
395
|
+
### SVG Processing Commands
|
|
396
|
+
|
|
397
|
+
#### split-paths
|
|
398
|
+
Split compound SVG paths into separate path elements.
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
SVG2DrawIOLib split-paths icon.svg -o icon-split.svg [OPTIONS]
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
**Options:**
|
|
405
|
+
- `--output, -o`: Output SVG file path (required)
|
|
406
|
+
- `--verbose, -v`: Debug logging
|
|
407
|
+
- `--quiet, -q`: Suppress output
|
|
408
|
+
|
|
239
409
|
## Scaling Behavior
|
|
240
410
|
|
|
241
411
|
### Proportional Scaling (--max-size)
|
|
@@ -324,21 +494,34 @@ Updated Library XML File
|
|
|
324
494
|
|
|
325
495
|
To enable color editing in DrawIO, SVG elements need CSS classes with embedded styles (see [DrawIO documentation](https://www.diagrams.net/doc/faq/svg-edit-colours)).
|
|
326
496
|
|
|
497
|
+
**CSS Modes:**
|
|
498
|
+
- `fill` (default): Generates CSS rules for fill colors only
|
|
499
|
+
- `stroke`: Generates CSS rules for stroke colors only
|
|
500
|
+
- `both`: Generates CSS rules for both fill and stroke colors
|
|
501
|
+
|
|
327
502
|
**Input SVG:**
|
|
328
503
|
```xml
|
|
329
504
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
|
330
|
-
<path d="M10,0C4.48,0,0,4.48,0,10..." />
|
|
505
|
+
<path d="M10,0C4.48,0,0,4.48,0,10..." fill="#ff0000" stroke="#0000ff" />
|
|
331
506
|
</svg>
|
|
332
507
|
```
|
|
333
508
|
|
|
334
|
-
**Output with CSS (--css
|
|
509
|
+
**Output with CSS (--css --css-mode both):**
|
|
335
510
|
```xml
|
|
336
511
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
|
|
512
|
+
<defs>
|
|
513
|
+
<style type="text/css">.path0{fill:#ff0000;stroke:#0000ff;}</style>
|
|
514
|
+
</defs>
|
|
337
515
|
<path d="M10,0C4.48,0,0,4.48,0,10..." class="path0" />
|
|
338
|
-
<style type="text/css">.path0{fill:#000000;}</style>
|
|
339
516
|
</svg>
|
|
340
517
|
```
|
|
341
518
|
|
|
519
|
+
**Special Value Handling:**
|
|
520
|
+
- `fill="none"` and `stroke="none"` are preserved (no CSS rule generated)
|
|
521
|
+
- `currentColor` is preserved by default (can be disabled with `--no-preserve-current-color`)
|
|
522
|
+
- Style attributes (`style="fill:#fff"`) are parsed alongside direct attributes
|
|
523
|
+
- Only the first class is used for CSS selector when multiple classes exist
|
|
524
|
+
|
|
342
525
|
### Data URI Encoding
|
|
343
526
|
|
|
344
527
|
SVG is encoded as a data URI using base64. Note: `;base64` is omitted from the MIME type as it conflicts with DrawIO's style syntax.
|
|
@@ -485,10 +668,10 @@ logger.error("Error messages")
|
|
|
485
668
|
- Complete workflows
|
|
486
669
|
|
|
487
670
|
### Coverage
|
|
488
|
-
-
|
|
671
|
+
- 94% overall coverage
|
|
489
672
|
- 100% coverage on models
|
|
490
|
-
-
|
|
491
|
-
-
|
|
673
|
+
- 90%+ coverage on core logic
|
|
674
|
+
- 85%+ coverage on CLI
|
|
492
675
|
|
|
493
676
|
## Public API
|
|
494
677
|
|
|
@@ -503,6 +686,9 @@ from SVG2DrawIOLib import (
|
|
|
503
686
|
# Processors
|
|
504
687
|
SVGProcessor,
|
|
505
688
|
LibraryManager,
|
|
689
|
+
IconAnalyzer,
|
|
690
|
+
LibraryValidator,
|
|
691
|
+
PathSplitter,
|
|
506
692
|
|
|
507
693
|
# Version
|
|
508
694
|
__version__,
|
|
@@ -539,29 +725,30 @@ from SVG2DrawIOLib import (
|
|
|
539
725
|
|
|
540
726
|
Potential additions for future versions:
|
|
541
727
|
|
|
542
|
-
1. **
|
|
543
|
-
-
|
|
544
|
-
-
|
|
545
|
-
-
|
|
728
|
+
1. **Advanced CSS Features**
|
|
729
|
+
- Support for gradients and patterns
|
|
730
|
+
- Multiple color themes per icon
|
|
731
|
+
- CSS variable support
|
|
546
732
|
|
|
547
733
|
2. **Library Merging**
|
|
548
734
|
- Combine multiple libraries
|
|
549
735
|
- Conflict resolution strategies
|
|
736
|
+
- Selective merging
|
|
550
737
|
|
|
551
738
|
3. **Icon Modification**
|
|
552
|
-
- Resize existing icons
|
|
553
|
-
-
|
|
739
|
+
- Resize existing icons in library
|
|
740
|
+
- Batch color changes
|
|
554
741
|
- Update metadata
|
|
555
742
|
|
|
556
743
|
4. **Export Formats**
|
|
557
|
-
- Export to
|
|
558
|
-
- Generate
|
|
744
|
+
- Export to PNG/JPG previews
|
|
745
|
+
- Generate icon catalogs
|
|
559
746
|
- Create documentation
|
|
560
747
|
|
|
561
|
-
5. **Validation**
|
|
562
|
-
-
|
|
563
|
-
-
|
|
564
|
-
-
|
|
748
|
+
5. **Advanced Validation**
|
|
749
|
+
- SVG optimization suggestions
|
|
750
|
+
- Accessibility checks
|
|
751
|
+
- Performance analysis
|
|
565
752
|
|
|
566
753
|
## Adding New CLI Commands
|
|
567
754
|
|
|
@@ -5,6 +5,29 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.2.1] - 2026-02-09
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- **Documentation Improvements**: Significantly improved documentation for v1.2.0 features in README.md, QUICKSTART.md, ARCHITECTURE.md, and CONTRIBUTING.md:
|
|
13
|
+
- Added documentation for new commands: `extract`, `rename`, `inspect`, `validate`
|
|
14
|
+
- Enhanced CSS feature documentation with detailed explanations of `--css-mode`, `--css-stroke-color`, and `--preserve-current-color` options
|
|
15
|
+
- Added `--split-by-folder` feature documentation with directory structure examples
|
|
16
|
+
- Reorganized command documentation into three logical groups: Library Management, Library Inspection, and SVG Processing
|
|
17
|
+
- Clarified `--tag` option with practical examples showing when and how to target different SVG element types (path, circle, rect, ellipse)
|
|
18
|
+
- Updated Python API examples to demonstrate new features including `IconAnalyzer` service and `rename_icon()` method
|
|
19
|
+
- Enhanced architecture overview with descriptions of new service classes (`IconAnalyzer`, `LibraryValidator`, `PathSplitter`) and helper modules (`create_helpers.py`)
|
|
20
|
+
- Updated module structure diagram to reflect all new files and commands
|
|
21
|
+
- Documented CSS mode behavior and special value handling in detail
|
|
22
|
+
- Expanded CONTRIBUTING.md with coding guidelines, providing detailed inline guidance on:
|
|
23
|
+
- SOLID principles and separation of concerns
|
|
24
|
+
- Code style, naming conventions, and formatting rules
|
|
25
|
+
- Documentation standards with Google-style docstring examples
|
|
26
|
+
- Error handling and logging best practices
|
|
27
|
+
- Testing structure and coverage requirements
|
|
28
|
+
- CLI development patterns and best practices
|
|
29
|
+
- Performance and security considerations
|
|
30
|
+
|
|
8
31
|
## [1.2.0] - 2026-02-08
|
|
9
32
|
|
|
10
33
|
### Added
|