autosar-calltree 0.3.3__tar.gz → 0.5.0__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.
Files changed (30) hide show
  1. {autosar_calltree-0.3.3/src/autosar_calltree.egg-info → autosar_calltree-0.5.0}/PKG-INFO +222 -29
  2. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/README.md +222 -29
  3. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/pyproject.toml +1 -1
  4. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/analyzers/call_tree_builder.py +9 -1
  5. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/cli/main.py +42 -3
  6. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/database/models.py +19 -1
  7. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/generators/__init__.py +2 -1
  8. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/generators/mermaid_generator.py +9 -0
  9. autosar_calltree-0.5.0/src/autosar_calltree/generators/xmi_generator.py +416 -0
  10. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/parsers/c_parser.py +109 -22
  11. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/version.py +1 -1
  12. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0/src/autosar_calltree.egg-info}/PKG-INFO +222 -29
  13. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree.egg-info/SOURCES.txt +1 -0
  14. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/LICENSE +0 -0
  15. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/MANIFEST.in +0 -0
  16. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/setup.cfg +0 -0
  17. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/setup.py +0 -0
  18. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/__init__.py +0 -0
  19. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/analyzers/__init__.py +0 -0
  20. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/cli/__init__.py +0 -0
  21. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/config/__init__.py +0 -0
  22. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/config/module_config.py +0 -0
  23. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/database/__init__.py +0 -0
  24. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/database/function_database.py +0 -0
  25. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/parsers/__init__.py +0 -0
  26. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree/parsers/autosar_parser.py +0 -0
  27. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree.egg-info/dependency_links.txt +0 -0
  28. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree.egg-info/entry_points.txt +0 -0
  29. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree.egg-info/requires.txt +0 -0
  30. {autosar_calltree-0.3.3 → autosar_calltree-0.5.0}/src/autosar_calltree.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autosar-calltree
3
- Version: 0.3.3
3
+ Version: 0.5.0
4
4
  Summary: A Python tool to analyze C/AUTOSAR codebases and generate function call trees with Mermaid and XMI output
5
5
  Author-email: melodypapa <melodypapa@outlook.com>
6
6
  Maintainer-email: melodypapa <melodypapa@outlook.com>
@@ -58,17 +58,181 @@ A powerful Python package to analyze C/AUTOSAR codebases and generate function c
58
58
  - 🔍 **Static Analysis**: Analyzes C source code without compilation
59
59
  - 📊 **Multiple Output Formats**:
60
60
  - Mermaid sequence diagrams (Markdown)
61
- - XMI/UML 2.5 (importable to Enterprise Architect, MagicDraw, etc.) - *planned*
61
+ - XMI/UML 2.5 (importable to Enterprise Architect, Visual Paradigm, etc.)
62
62
  - JSON (for custom processing) - *planned*
63
63
  - 🏗️ **SW Module Support**: Map C files to SW modules via YAML configuration for architecture-level diagrams
64
64
  - 📈 **Module-Aware Diagrams**: Generate diagrams with SW module names as participants
65
65
  - 🎯 **Parameter Display**: Function parameters shown in sequence diagram calls for better visibility
66
+ - 🔄 **Automatic Conditional Detection**: Automatically detects `if`/`else` statements and generates `opt` blocks with actual conditions (Mermaid and XMI)
66
67
  - 🚀 **Performance**: Intelligent caching for fast repeated analysis with file-by-file progress reporting
67
68
  - 🎯 **Depth Control**: Configurable call tree depth
68
69
  - 🔄 **Circular Dependency Detection**: Identifies recursive calls and cycles
69
70
  - 📊 **Statistics**: Detailed analysis statistics including module distribution
70
71
  - 📝 **Clean Diagrams**: Return statements omitted by default for cleaner sequence diagrams (configurable)
71
72
 
73
+ ## What's New
74
+
75
+ ### Version 0.5.0 (2026-02-04)
76
+
77
+ **🎉 Major Feature: Automatic Conditional Call Detection with Opt/Alt/Else Blocks**
78
+
79
+ This release adds intelligent parsing of conditional function calls, automatically detecting `if`/`else` blocks in your C code and representing them as `opt`/`alt`/`else` blocks in both Mermaid and XMI output formats.
80
+
81
+ **Mermaid Example**:
82
+
83
+ **Source Code**:
84
+ ```c
85
+ FUNC(void, RTE_CODE) Demo_Update(VAR(uint32, AUTOMATIC) update_mode)
86
+ {
87
+ SW_UpdateState(update_mode);
88
+
89
+ if (update_mode == 0x05) {
90
+ COM_SendLINMessage(0x456, (uint8*)0x20003000);
91
+ }
92
+ }
93
+ ```
94
+
95
+ **Generated Mermaid Diagram**:
96
+ ```mermaid
97
+ sequenceDiagram
98
+ participant Demo_Update
99
+ participant COM_SendLINMessage
100
+ participant SW_UpdateState
101
+
102
+ Demo_Update->>SW_UpdateState: call(new_state)
103
+ opt update_mode == 0x05
104
+ Demo_Update->>COM_SendLINMessage: call(msg_id, data)
105
+ end
106
+ ```
107
+
108
+ **XMI Example**:
109
+ ```xml
110
+ <uml:fragment name="opt" interactionOperator="opt">
111
+ <uml:operand name="update_mode == 0x05">
112
+ <uml:message name="COM_SendLINMessage" signature="COM_SendLINMessage(msg_id, data)">
113
+ <!-- message events -->
114
+ </uml:message>
115
+ </uml:operand>
116
+ </uml:fragment>
117
+ ```
118
+
119
+ **Benefits**:
120
+ - ✅ No manual configuration required - automatic detection
121
+ - ✅ Shows actual condition text for better understanding
122
+ - ✅ Supports nested conditionals
123
+ - ✅ Handles `if`, `else if`, and `else` statements
124
+ - ✅ Works with both Mermaid and XMI output formats
125
+ - ✅ XMI uses UML combined fragments (standard UML 2.5 representation)
126
+
127
+ **Technical Changes**:
128
+ - `FunctionCall` model extended with `is_conditional` and `condition` fields
129
+ - `CallTreeNode` extended with `is_optional` and `condition` fields
130
+ - `CParser` enhanced with line-by-line conditional context tracking
131
+ - `MermaidGenerator` supports `opt`, `alt`, and `else` blocks
132
+ - `XMIGenerator` supports UML combined fragments
133
+ - 298 tests passing with 89% code coverage
134
+
135
+ ## Changelog
136
+
137
+ ### [0.5.0] - 2026-02-04
138
+
139
+ #### Added
140
+ - **Conditional function call tracking**: Automatic detection of `if`/`else` blocks with condition text extraction
141
+ - **Mermaid opt/alt/else blocks**: Generate `opt`, `alt`, and `else` blocks for conditional calls
142
+ - **XMI combined fragments**: UML 2.5 compliant `opt`/`alt`/`else` fragment generation
143
+ - **FunctionCall model**: Extended with `is_conditional` and `condition` fields
144
+ - **CallTreeNode model**: Extended with `is_optional` and `condition` fields
145
+ - **CParser enhancements**: Line-by-line parsing to track conditional context
146
+ - Requirements documentation for conditional call tracking (SWR_MODEL_00026-00028)
147
+
148
+ #### Fixed
149
+ - Linting errors (flake8 W292, W391) for proper file endings
150
+ - Type annotations in `c_parser.py:442` for mypy compliance
151
+
152
+ #### Technical
153
+ - 298 tests passing, 89% code coverage
154
+ - All CI quality checks passing (ruff, isort, flake8, mypy)
155
+ - Python 3.8-3.12 test matrix
156
+
157
+ ---
158
+
159
+ ### [0.4.0] - 2026-02-03
160
+
161
+ #### Added
162
+ - **XMI/UML 2.5 output format**: Complete XMI generation with UML 2.5 compliance
163
+ - **XMIGenerator**: New generator class for XMI document creation
164
+ - **CLI `--format xmi` option**: Support for XMI output format
165
+ - **CLI `--format both` option**: Generate both Mermaid and XMI simultaneously
166
+ - **XMI requirements documentation**: `docs/requirements/requirements_xmi.md`
167
+ - **UML combined fragments**: Support for `opt`, `alt`, `else` interactions
168
+ - **XMI demo output**: `demo/demo_main.xmi` example file
169
+
170
+ #### Technical
171
+ - XMI documents importable into Enterprise Architect, Visual Paradigm, MagicDraw
172
+ - Proper XML namespaces and structure (UML 2.5, XMI 2.5)
173
+ - Message events with sendEvent and receiveEvent elements
174
+
175
+ ---
176
+
177
+ ### [0.3.3] - 2026-02-02
178
+
179
+ #### Fixed
180
+ - **AUTOSAR macro false positives**: Performance degradation caused by incorrect macro matching
181
+ - Parser optimization to reduce false positive detections
182
+ - Improved AUTOSAR pattern matching accuracy
183
+
184
+ ---
185
+
186
+ ### [0.3.2] - 2026-02-01
187
+
188
+ #### Added
189
+ - **File size display**: Show file sizes during processing in verbose mode
190
+ - Enhanced progress reporting with line counts and file sizes
191
+ - Improved user feedback for large file processing
192
+
193
+ ---
194
+
195
+ ### [0.3.1] - 2026-01-31
196
+
197
+ #### Added
198
+ - **Verbose file progress**: File-by-file progress display during database building
199
+ - **Line count reporting**: Show number of lines processed per file
200
+ - **Enhanced cache loading**: File-by-file progress when loading from cache
201
+ - **C parser line-by-line tests**: Comprehensive testing for line-by-line processing
202
+
203
+ #### Fixed
204
+ - Import sorting to pass isort checks
205
+ - Minor documentation updates
206
+
207
+ ---
208
+
209
+ ### [0.3.0] - 2026-01-30
210
+
211
+ #### Added
212
+ - **SW Module Configuration System**: YAML-based file-to-module mapping
213
+ - **Module-aware diagrams**: Generate diagrams with SW module names as participants
214
+ - **Comprehensive test suite**: 298 tests across all modules (89% coverage)
215
+ - **Requirements traceability**: Complete traceability matrix between requirements and tests
216
+ - **Integration tests**: End-to-end CLI testing
217
+ - **PyPI publishing workflow**: Automated PyPI releases with OIDC trusted publishing
218
+ - **ModuleConfig class**: Load, validate, and perform module lookups
219
+ - **Module assignment**: Functions tagged with SW module information
220
+ - **FunctionDatabase integration**: Module assignments preserved in cache
221
+ - **CLI `--use-module-names` option**: Enable module-level diagrams
222
+ - **CLI `--module-config` option**: Specify module mapping YAML file
223
+
224
+ #### Technical
225
+ - Glob pattern support for file mappings (e.g., `hw_*.c`)
226
+ - Default module fallback for unmapped files
227
+ - Module lookup caching for performance
228
+ - Cache preserves module assignments across runs
229
+
230
+ ---
231
+
232
+ ### Earlier Versions
233
+
234
+ **0.2.x** - Initial development releases with basic AUTOSAR parsing and Mermaid output
235
+
72
236
  ## Installation
73
237
 
74
238
  ```bash
@@ -97,6 +261,9 @@ calltree --start-function Demo_Init --source-dir demo --module-config demo/modul
97
261
  # Specify depth and output
98
262
  calltree --start-function Demo_Init --max-depth 2 -o output.md
99
263
 
264
+ # Generate XMI format (with opt block support)
265
+ calltree --start-function Demo_MainFunction --source-dir demo --format xmi --output demo/demo.xmi
266
+
100
267
  # Verbose mode with detailed statistics and cache progress
101
268
  calltree --start-function Demo_Init --verbose
102
269
  ```
@@ -158,7 +325,7 @@ Options:
158
325
 
159
326
  ## Output Examples
160
327
 
161
- ### Mermaid Sequence Diagram
328
+ ### Mermaid Sequence Diagram with Opt Blocks
162
329
 
163
330
  ```mermaid
164
331
  sequenceDiagram
@@ -168,31 +335,55 @@ sequenceDiagram
168
335
  participant SoftwareModule
169
336
 
170
337
  DemoModule->>CommunicationModule: COM_InitCommunication(baud_rate, buffer_size)
171
- CommunicationModule->>CommunicationModule: COM_InitCAN
172
- CommunicationModule->>CommunicationModule: COM_InitEthernet
173
- CommunicationModule->>CommunicationModule: COM_InitLIN
174
- DemoModule->>DemoModule: Demo_InitVariables(config_mode)
175
- DemoModule->>HardwareModule: HW_InitHardware(clock_freq, gpio_mask)
176
- HardwareModule->>HardwareModule: HW_InitADC
177
- HardwareModule->>HardwareModule: HW_InitClock
178
- HardwareModule->>HardwareModule: HW_InitGPIO
179
- HardwareModule->>HardwareModule: HW_InitPWM
180
- DemoModule->>SoftwareModule: SW_InitSoftware(state, config)
181
- SoftwareModule->>SoftwareModule: SW_InitConfig
182
- SoftwareModule->>SoftwareModule: SW_InitState
338
+ opt mode > 0x00
339
+ DemoModule->>DemoModule: Demo_Update(mode)
340
+ opt mode == 0x05
341
+ DemoModule->>CommunicationModule: COM_SendLINMessage(msg_id, data)
342
+ end
343
+ DemoModule->>SoftwareModule: SW_UpdateState(new_state)
344
+ end
345
+ DemoModule->>HardwareModule: HW_ReadSensor(sensor_id)
346
+ DemoModule->>SoftwareModule: SW_ProcessData(data, length)
183
347
  ```
184
348
 
185
349
  **Key Features**:
186
- - Participants appear in the order they are first encountered in the call tree
187
- - Function parameters are displayed in the call arrows (e.g., `COM_InitCommunication(baud_rate, buffer_size)`)
350
+ - Conditional calls are automatically wrapped in `opt` blocks
351
+ - Shows actual condition text from source code (e.g., `mode > 0x00`, `mode == 0x05`)
352
+ - Supports nested conditionals
353
+ - Participants appear in the order they are first encountered
354
+ - Function parameters are displayed in the call arrows
188
355
  - Return statements are omitted by default for cleaner visualization
189
356
  - Module names are used as participants when `--use-module-names` is enabled
190
357
 
358
+ ### XMI Output with Opt Blocks
359
+
360
+ The XMI output also supports opt blocks using UML combined fragments:
361
+
362
+ ```xml
363
+ <uml:fragment name="opt" interactionOperator="opt">
364
+ <uml:operand name="update_mode == 0x05">
365
+ <uml:message name="COM_SendLINMessage"
366
+ signature="COM_SendLINMessage(msg_id, data)"
367
+ messageSort="synchCall">
368
+ <uml:sendEvent xmi:id="calltree_22"/>
369
+ <uml:receiveEvent xmi:id="calltree_23"/>
370
+ </uml:message>
371
+ </uml:operand>
372
+ </uml:fragment>
373
+ ```
374
+
375
+ **XMI Features**:
376
+ - UML 2.5 compliant XMI documents
377
+ - Combined fragments with `opt` interaction operator
378
+ - Operand elements display the condition text
379
+ - Can be imported into UML tools like Enterprise Architect, Visual Paradigm, MagicDraw
380
+ - Proper XML structure with correct namespaces
381
+
191
382
  ### Generated Markdown Structure
192
383
 
193
384
  The tool generates comprehensive Markdown files with:
194
385
  - Metadata header (timestamp, settings, statistics)
195
- - Mermaid sequence diagram with function parameters
386
+ - Mermaid sequence diagram with function parameters and opt blocks
196
387
  - Function details table with parameter information
197
388
  - Text-based call tree
198
389
  - Circular dependency warnings
@@ -261,6 +452,7 @@ calltree --start-function Demo_Init --module-config demo/module_mapping.yaml --u
261
452
  This generates diagrams with:
262
453
  - **Participants**: SW module names (HardwareModule, SoftwareModule, etc.) in the order they are first encountered
263
454
  - **Arrows**: Function names with parameters being called between modules
455
+ - **Opt Blocks**: Conditional calls wrapped with actual condition text
264
456
  - **Function Table**: Includes module column showing each function's SW module
265
457
  - **Clean Visualization**: Return statements omitted by default
266
458
 
@@ -284,7 +476,7 @@ autosar-calltree/
284
476
  │ ├── parsers/ # Code parsers (AUTOSAR, C)
285
477
  │ ├── analyzers/ # Analysis logic (call tree, dependencies)
286
478
  │ ├── database/ # Data models and caching
287
- │ ├── generators/ # Output generators (Mermaid)
479
+ │ ├── generators/ # Output generators (Mermaid, XMI)
288
480
  │ └── utils/ # Utilities (empty, for future use)
289
481
  ├── test_demo/ # Demo AUTOSAR C files for testing
290
482
  │ ├── demo.c
@@ -302,7 +494,7 @@ autosar-calltree/
302
494
 
303
495
  ### Running Tests
304
496
 
305
- The project has **comprehensive test coverage** with 278 tests across all modules:
497
+ The project has **comprehensive test coverage** with 298 tests across all modules:
306
498
 
307
499
  ```bash
308
500
  # Run all tests
@@ -336,20 +528,20 @@ pytest --cov=autosar_calltree --cov-report=html --cov-report=term --omit=tests/
336
528
 
337
529
  ### Test Coverage
338
530
 
339
- The project maintains **94% code coverage** across all modules:
531
+ The project maintains **89% code coverage** across all modules:
340
532
 
341
533
  | Module | Coverage | Tests |
342
534
  |--------|----------|-------|
343
- | Models | 100% | 25 |
535
+ | Models | 97% | 28 |
344
536
  | AUTOSAR Parser | 97% | 15 |
345
537
  | C Parser | 86% | 18 |
346
- | Database | 80% | 20 |
347
- | Analyzers | 94% | 20 |
538
+ | Database | 83% | 20 |
539
+ | Analyzers | 95% | 20 |
348
540
  | Config | 97% | 25 |
349
- | Generators | 96% | 31 |
350
- | CLI (Integration) | ~90% | 14 |
351
- | End-to-End | ~90% | 110 |
352
- | **Total** | **94%** | **278** |
541
+ | Generators | 89% | 45 |
542
+ | CLI (Integration) | 90% | 14 |
543
+ | End-to-End | ~90% | 120 |
544
+ | **Total** | **89%** | **298** |
353
545
 
354
546
  ### Code Quality
355
547
 
@@ -469,7 +661,8 @@ MIT License - see [LICENSE](LICENSE) file for details.
469
661
  - [ ] Multi-threading for large codebases
470
662
  - [ ] Function complexity metrics
471
663
  - [ ] Dead code detection
472
- - [ ] XMI/UML 2.5 output format
664
+ - [x] XMI/UML 2.5 output format with opt block support
665
+ - [x] Automatic conditional call detection with opt blocks
473
666
 
474
667
  ## Support
475
668
 
@@ -12,17 +12,181 @@ A powerful Python package to analyze C/AUTOSAR codebases and generate function c
12
12
  - 🔍 **Static Analysis**: Analyzes C source code without compilation
13
13
  - 📊 **Multiple Output Formats**:
14
14
  - Mermaid sequence diagrams (Markdown)
15
- - XMI/UML 2.5 (importable to Enterprise Architect, MagicDraw, etc.) - *planned*
15
+ - XMI/UML 2.5 (importable to Enterprise Architect, Visual Paradigm, etc.)
16
16
  - JSON (for custom processing) - *planned*
17
17
  - 🏗️ **SW Module Support**: Map C files to SW modules via YAML configuration for architecture-level diagrams
18
18
  - 📈 **Module-Aware Diagrams**: Generate diagrams with SW module names as participants
19
19
  - 🎯 **Parameter Display**: Function parameters shown in sequence diagram calls for better visibility
20
+ - 🔄 **Automatic Conditional Detection**: Automatically detects `if`/`else` statements and generates `opt` blocks with actual conditions (Mermaid and XMI)
20
21
  - 🚀 **Performance**: Intelligent caching for fast repeated analysis with file-by-file progress reporting
21
22
  - 🎯 **Depth Control**: Configurable call tree depth
22
23
  - 🔄 **Circular Dependency Detection**: Identifies recursive calls and cycles
23
24
  - 📊 **Statistics**: Detailed analysis statistics including module distribution
24
25
  - 📝 **Clean Diagrams**: Return statements omitted by default for cleaner sequence diagrams (configurable)
25
26
 
27
+ ## What's New
28
+
29
+ ### Version 0.5.0 (2026-02-04)
30
+
31
+ **🎉 Major Feature: Automatic Conditional Call Detection with Opt/Alt/Else Blocks**
32
+
33
+ This release adds intelligent parsing of conditional function calls, automatically detecting `if`/`else` blocks in your C code and representing them as `opt`/`alt`/`else` blocks in both Mermaid and XMI output formats.
34
+
35
+ **Mermaid Example**:
36
+
37
+ **Source Code**:
38
+ ```c
39
+ FUNC(void, RTE_CODE) Demo_Update(VAR(uint32, AUTOMATIC) update_mode)
40
+ {
41
+ SW_UpdateState(update_mode);
42
+
43
+ if (update_mode == 0x05) {
44
+ COM_SendLINMessage(0x456, (uint8*)0x20003000);
45
+ }
46
+ }
47
+ ```
48
+
49
+ **Generated Mermaid Diagram**:
50
+ ```mermaid
51
+ sequenceDiagram
52
+ participant Demo_Update
53
+ participant COM_SendLINMessage
54
+ participant SW_UpdateState
55
+
56
+ Demo_Update->>SW_UpdateState: call(new_state)
57
+ opt update_mode == 0x05
58
+ Demo_Update->>COM_SendLINMessage: call(msg_id, data)
59
+ end
60
+ ```
61
+
62
+ **XMI Example**:
63
+ ```xml
64
+ <uml:fragment name="opt" interactionOperator="opt">
65
+ <uml:operand name="update_mode == 0x05">
66
+ <uml:message name="COM_SendLINMessage" signature="COM_SendLINMessage(msg_id, data)">
67
+ <!-- message events -->
68
+ </uml:message>
69
+ </uml:operand>
70
+ </uml:fragment>
71
+ ```
72
+
73
+ **Benefits**:
74
+ - ✅ No manual configuration required - automatic detection
75
+ - ✅ Shows actual condition text for better understanding
76
+ - ✅ Supports nested conditionals
77
+ - ✅ Handles `if`, `else if`, and `else` statements
78
+ - ✅ Works with both Mermaid and XMI output formats
79
+ - ✅ XMI uses UML combined fragments (standard UML 2.5 representation)
80
+
81
+ **Technical Changes**:
82
+ - `FunctionCall` model extended with `is_conditional` and `condition` fields
83
+ - `CallTreeNode` extended with `is_optional` and `condition` fields
84
+ - `CParser` enhanced with line-by-line conditional context tracking
85
+ - `MermaidGenerator` supports `opt`, `alt`, and `else` blocks
86
+ - `XMIGenerator` supports UML combined fragments
87
+ - 298 tests passing with 89% code coverage
88
+
89
+ ## Changelog
90
+
91
+ ### [0.5.0] - 2026-02-04
92
+
93
+ #### Added
94
+ - **Conditional function call tracking**: Automatic detection of `if`/`else` blocks with condition text extraction
95
+ - **Mermaid opt/alt/else blocks**: Generate `opt`, `alt`, and `else` blocks for conditional calls
96
+ - **XMI combined fragments**: UML 2.5 compliant `opt`/`alt`/`else` fragment generation
97
+ - **FunctionCall model**: Extended with `is_conditional` and `condition` fields
98
+ - **CallTreeNode model**: Extended with `is_optional` and `condition` fields
99
+ - **CParser enhancements**: Line-by-line parsing to track conditional context
100
+ - Requirements documentation for conditional call tracking (SWR_MODEL_00026-00028)
101
+
102
+ #### Fixed
103
+ - Linting errors (flake8 W292, W391) for proper file endings
104
+ - Type annotations in `c_parser.py:442` for mypy compliance
105
+
106
+ #### Technical
107
+ - 298 tests passing, 89% code coverage
108
+ - All CI quality checks passing (ruff, isort, flake8, mypy)
109
+ - Python 3.8-3.12 test matrix
110
+
111
+ ---
112
+
113
+ ### [0.4.0] - 2026-02-03
114
+
115
+ #### Added
116
+ - **XMI/UML 2.5 output format**: Complete XMI generation with UML 2.5 compliance
117
+ - **XMIGenerator**: New generator class for XMI document creation
118
+ - **CLI `--format xmi` option**: Support for XMI output format
119
+ - **CLI `--format both` option**: Generate both Mermaid and XMI simultaneously
120
+ - **XMI requirements documentation**: `docs/requirements/requirements_xmi.md`
121
+ - **UML combined fragments**: Support for `opt`, `alt`, `else` interactions
122
+ - **XMI demo output**: `demo/demo_main.xmi` example file
123
+
124
+ #### Technical
125
+ - XMI documents importable into Enterprise Architect, Visual Paradigm, MagicDraw
126
+ - Proper XML namespaces and structure (UML 2.5, XMI 2.5)
127
+ - Message events with sendEvent and receiveEvent elements
128
+
129
+ ---
130
+
131
+ ### [0.3.3] - 2026-02-02
132
+
133
+ #### Fixed
134
+ - **AUTOSAR macro false positives**: Performance degradation caused by incorrect macro matching
135
+ - Parser optimization to reduce false positive detections
136
+ - Improved AUTOSAR pattern matching accuracy
137
+
138
+ ---
139
+
140
+ ### [0.3.2] - 2026-02-01
141
+
142
+ #### Added
143
+ - **File size display**: Show file sizes during processing in verbose mode
144
+ - Enhanced progress reporting with line counts and file sizes
145
+ - Improved user feedback for large file processing
146
+
147
+ ---
148
+
149
+ ### [0.3.1] - 2026-01-31
150
+
151
+ #### Added
152
+ - **Verbose file progress**: File-by-file progress display during database building
153
+ - **Line count reporting**: Show number of lines processed per file
154
+ - **Enhanced cache loading**: File-by-file progress when loading from cache
155
+ - **C parser line-by-line tests**: Comprehensive testing for line-by-line processing
156
+
157
+ #### Fixed
158
+ - Import sorting to pass isort checks
159
+ - Minor documentation updates
160
+
161
+ ---
162
+
163
+ ### [0.3.0] - 2026-01-30
164
+
165
+ #### Added
166
+ - **SW Module Configuration System**: YAML-based file-to-module mapping
167
+ - **Module-aware diagrams**: Generate diagrams with SW module names as participants
168
+ - **Comprehensive test suite**: 298 tests across all modules (89% coverage)
169
+ - **Requirements traceability**: Complete traceability matrix between requirements and tests
170
+ - **Integration tests**: End-to-end CLI testing
171
+ - **PyPI publishing workflow**: Automated PyPI releases with OIDC trusted publishing
172
+ - **ModuleConfig class**: Load, validate, and perform module lookups
173
+ - **Module assignment**: Functions tagged with SW module information
174
+ - **FunctionDatabase integration**: Module assignments preserved in cache
175
+ - **CLI `--use-module-names` option**: Enable module-level diagrams
176
+ - **CLI `--module-config` option**: Specify module mapping YAML file
177
+
178
+ #### Technical
179
+ - Glob pattern support for file mappings (e.g., `hw_*.c`)
180
+ - Default module fallback for unmapped files
181
+ - Module lookup caching for performance
182
+ - Cache preserves module assignments across runs
183
+
184
+ ---
185
+
186
+ ### Earlier Versions
187
+
188
+ **0.2.x** - Initial development releases with basic AUTOSAR parsing and Mermaid output
189
+
26
190
  ## Installation
27
191
 
28
192
  ```bash
@@ -51,6 +215,9 @@ calltree --start-function Demo_Init --source-dir demo --module-config demo/modul
51
215
  # Specify depth and output
52
216
  calltree --start-function Demo_Init --max-depth 2 -o output.md
53
217
 
218
+ # Generate XMI format (with opt block support)
219
+ calltree --start-function Demo_MainFunction --source-dir demo --format xmi --output demo/demo.xmi
220
+
54
221
  # Verbose mode with detailed statistics and cache progress
55
222
  calltree --start-function Demo_Init --verbose
56
223
  ```
@@ -112,7 +279,7 @@ Options:
112
279
 
113
280
  ## Output Examples
114
281
 
115
- ### Mermaid Sequence Diagram
282
+ ### Mermaid Sequence Diagram with Opt Blocks
116
283
 
117
284
  ```mermaid
118
285
  sequenceDiagram
@@ -122,31 +289,55 @@ sequenceDiagram
122
289
  participant SoftwareModule
123
290
 
124
291
  DemoModule->>CommunicationModule: COM_InitCommunication(baud_rate, buffer_size)
125
- CommunicationModule->>CommunicationModule: COM_InitCAN
126
- CommunicationModule->>CommunicationModule: COM_InitEthernet
127
- CommunicationModule->>CommunicationModule: COM_InitLIN
128
- DemoModule->>DemoModule: Demo_InitVariables(config_mode)
129
- DemoModule->>HardwareModule: HW_InitHardware(clock_freq, gpio_mask)
130
- HardwareModule->>HardwareModule: HW_InitADC
131
- HardwareModule->>HardwareModule: HW_InitClock
132
- HardwareModule->>HardwareModule: HW_InitGPIO
133
- HardwareModule->>HardwareModule: HW_InitPWM
134
- DemoModule->>SoftwareModule: SW_InitSoftware(state, config)
135
- SoftwareModule->>SoftwareModule: SW_InitConfig
136
- SoftwareModule->>SoftwareModule: SW_InitState
292
+ opt mode > 0x00
293
+ DemoModule->>DemoModule: Demo_Update(mode)
294
+ opt mode == 0x05
295
+ DemoModule->>CommunicationModule: COM_SendLINMessage(msg_id, data)
296
+ end
297
+ DemoModule->>SoftwareModule: SW_UpdateState(new_state)
298
+ end
299
+ DemoModule->>HardwareModule: HW_ReadSensor(sensor_id)
300
+ DemoModule->>SoftwareModule: SW_ProcessData(data, length)
137
301
  ```
138
302
 
139
303
  **Key Features**:
140
- - Participants appear in the order they are first encountered in the call tree
141
- - Function parameters are displayed in the call arrows (e.g., `COM_InitCommunication(baud_rate, buffer_size)`)
304
+ - Conditional calls are automatically wrapped in `opt` blocks
305
+ - Shows actual condition text from source code (e.g., `mode > 0x00`, `mode == 0x05`)
306
+ - Supports nested conditionals
307
+ - Participants appear in the order they are first encountered
308
+ - Function parameters are displayed in the call arrows
142
309
  - Return statements are omitted by default for cleaner visualization
143
310
  - Module names are used as participants when `--use-module-names` is enabled
144
311
 
312
+ ### XMI Output with Opt Blocks
313
+
314
+ The XMI output also supports opt blocks using UML combined fragments:
315
+
316
+ ```xml
317
+ <uml:fragment name="opt" interactionOperator="opt">
318
+ <uml:operand name="update_mode == 0x05">
319
+ <uml:message name="COM_SendLINMessage"
320
+ signature="COM_SendLINMessage(msg_id, data)"
321
+ messageSort="synchCall">
322
+ <uml:sendEvent xmi:id="calltree_22"/>
323
+ <uml:receiveEvent xmi:id="calltree_23"/>
324
+ </uml:message>
325
+ </uml:operand>
326
+ </uml:fragment>
327
+ ```
328
+
329
+ **XMI Features**:
330
+ - UML 2.5 compliant XMI documents
331
+ - Combined fragments with `opt` interaction operator
332
+ - Operand elements display the condition text
333
+ - Can be imported into UML tools like Enterprise Architect, Visual Paradigm, MagicDraw
334
+ - Proper XML structure with correct namespaces
335
+
145
336
  ### Generated Markdown Structure
146
337
 
147
338
  The tool generates comprehensive Markdown files with:
148
339
  - Metadata header (timestamp, settings, statistics)
149
- - Mermaid sequence diagram with function parameters
340
+ - Mermaid sequence diagram with function parameters and opt blocks
150
341
  - Function details table with parameter information
151
342
  - Text-based call tree
152
343
  - Circular dependency warnings
@@ -215,6 +406,7 @@ calltree --start-function Demo_Init --module-config demo/module_mapping.yaml --u
215
406
  This generates diagrams with:
216
407
  - **Participants**: SW module names (HardwareModule, SoftwareModule, etc.) in the order they are first encountered
217
408
  - **Arrows**: Function names with parameters being called between modules
409
+ - **Opt Blocks**: Conditional calls wrapped with actual condition text
218
410
  - **Function Table**: Includes module column showing each function's SW module
219
411
  - **Clean Visualization**: Return statements omitted by default
220
412
 
@@ -238,7 +430,7 @@ autosar-calltree/
238
430
  │ ├── parsers/ # Code parsers (AUTOSAR, C)
239
431
  │ ├── analyzers/ # Analysis logic (call tree, dependencies)
240
432
  │ ├── database/ # Data models and caching
241
- │ ├── generators/ # Output generators (Mermaid)
433
+ │ ├── generators/ # Output generators (Mermaid, XMI)
242
434
  │ └── utils/ # Utilities (empty, for future use)
243
435
  ├── test_demo/ # Demo AUTOSAR C files for testing
244
436
  │ ├── demo.c
@@ -256,7 +448,7 @@ autosar-calltree/
256
448
 
257
449
  ### Running Tests
258
450
 
259
- The project has **comprehensive test coverage** with 278 tests across all modules:
451
+ The project has **comprehensive test coverage** with 298 tests across all modules:
260
452
 
261
453
  ```bash
262
454
  # Run all tests
@@ -290,20 +482,20 @@ pytest --cov=autosar_calltree --cov-report=html --cov-report=term --omit=tests/
290
482
 
291
483
  ### Test Coverage
292
484
 
293
- The project maintains **94% code coverage** across all modules:
485
+ The project maintains **89% code coverage** across all modules:
294
486
 
295
487
  | Module | Coverage | Tests |
296
488
  |--------|----------|-------|
297
- | Models | 100% | 25 |
489
+ | Models | 97% | 28 |
298
490
  | AUTOSAR Parser | 97% | 15 |
299
491
  | C Parser | 86% | 18 |
300
- | Database | 80% | 20 |
301
- | Analyzers | 94% | 20 |
492
+ | Database | 83% | 20 |
493
+ | Analyzers | 95% | 20 |
302
494
  | Config | 97% | 25 |
303
- | Generators | 96% | 31 |
304
- | CLI (Integration) | ~90% | 14 |
305
- | End-to-End | ~90% | 110 |
306
- | **Total** | **94%** | **278** |
495
+ | Generators | 89% | 45 |
496
+ | CLI (Integration) | 90% | 14 |
497
+ | End-to-End | ~90% | 120 |
498
+ | **Total** | **89%** | **298** |
307
499
 
308
500
  ### Code Quality
309
501
 
@@ -423,7 +615,8 @@ MIT License - see [LICENSE](LICENSE) file for details.
423
615
  - [ ] Multi-threading for large codebases
424
616
  - [ ] Function complexity metrics
425
617
  - [ ] Dead code detection
426
- - [ ] XMI/UML 2.5 output format
618
+ - [x] XMI/UML 2.5 output format with opt block support
619
+ - [x] Automatic conditional call detection with opt blocks
427
620
 
428
621
  ## Support
429
622
 
@@ -433,4 +626,4 @@ MIT License - see [LICENSE](LICENSE) file for details.
433
626
 
434
627
  ---
435
628
 
436
- **Made with ❤️ for the embedded systems community**
629
+ **Made with ❤️ for the embedded systems community**