-
Notifications
You must be signed in to change notification settings - Fork 0
E2E demo support #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| mscdocument CANAcquisition /* MSC AND */; | ||
| language ASN.1; | ||
| data dataview-uniq.asn; | ||
| /* CIF MSCDOCUMENT (0, 0) (4252, 2327) */ | ||
| mscdocument CANAcquisition /* MSC LEAF */; | ||
| language ASN.1; | ||
| data dataview-uniq.asn; | ||
| msc CANAcquisition; | ||
| /* CIF INSTANCE (0, 58) (320, 85) (800, 2159) */ | ||
| instance Service_Frontend; | ||
| /* CIF MESSAGE (161, 212) (934, 212) */ | ||
| out command to CANOpenMaster; | ||
| endinstance; | ||
| /* CIF INSTANCE (778, 58) (310, 85) (800, 2159) */ | ||
| instance CANOpenMaster; | ||
| /* CIF MESSAGE (161, 212) (934, 212) */ | ||
| in command from Service_Frontend; | ||
| /* CIF MESSAGE (934, 302) (1699, 302) */ | ||
| out pdu_out to CANOpenSlave; | ||
| /* CIF MESSAGE (1699, 392) (934, 392) */ | ||
| in pdu_in from CANOpenSlave; | ||
| /* CIF MESSAGE (934, 482) (2453, 482) */ | ||
| out submit to DataPool; | ||
| endinstance; | ||
| /* CIF INSTANCE (1556, 58) (286, 85) (800, 2159) */ | ||
| instance CANOpenSlave; | ||
| /* CIF MESSAGE (934, 302) (1699, 302) */ | ||
| in pdu_out from CANOpenMaster; | ||
| /* CIF MESSAGE (1699, 392) (934, 392) */ | ||
| out pdu_in to CANOpenMaster; | ||
| endinstance; | ||
| /* CIF INSTANCE (2357, 58) (188, 85) (800, 2159) */ | ||
| instance DataPool; | ||
| /* CIF MESSAGE (934, 482) (2453, 482) */ | ||
| in submit from CANOpenMaster; | ||
| endinstance; | ||
| endmsc; | ||
| endmscdocument; | ||
| endmscdocument; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| <% | ||
| ## E2E Diagram Generation | ||
| # Find all .msc files in the project directory | ||
|
|
||
| import os | ||
| import subprocess | ||
| import glob | ||
|
|
||
| # Find all .msc files in current directory and subdirectories | ||
| msc_files = glob.glob("**/*.msc", recursive=True) | ||
| msc_files.sort() | ||
|
|
||
| # Find the interfaceview.xml file | ||
| interfaceview_xml = None | ||
| for candidate in ["interfaceview.xml"]: | ||
| if os.path.exists(candidate): | ||
| interfaceview_xml = candidate | ||
| break | ||
|
|
||
| if not interfaceview_xml: | ||
| # Try to find it in subdirectories | ||
| candidates = glob.glob("**/interfaceview.xml", recursive=True) | ||
| if candidates: | ||
| interfaceview_xml = candidates[0] | ||
|
|
||
| # Generate E2E diagrams using SpaceCreator | ||
| def generate_e2e_diagram(msc_file, interfaceview_xml): | ||
| """Generate E2E diagram for an MSC file using SpaceCreator""" | ||
|
|
||
| # Get base name without extension for output | ||
| msc_basename = os.path.splitext(os.path.basename(msc_file))[0] | ||
| output_png = f"{msc_basename}.png" | ||
|
|
||
| # Store original directory | ||
| original_dir = os.getcwd() | ||
|
|
||
| # Get absolute path to output directory before any directory changes | ||
| abs_output_dir = None | ||
| if output_directory: | ||
| abs_output_dir = os.path.abspath(output_directory) | ||
|
|
||
| try: | ||
| # Get absolute paths | ||
| abs_msc_file = os.path.abspath(msc_file) | ||
| abs_interfaceview = os.path.abspath(interfaceview_xml) | ||
|
|
||
| # Generate temporary output name in current directory | ||
| temp_output_png = output_png | ||
|
|
||
| # Run SpaceCreator to generate E2E diagram | ||
| result = subprocess.run( | ||
| ["spacecreator.AppImage", "--e2eimagesaver", abs_interfaceview, abs_msc_file, temp_output_png], | ||
| check=False, | ||
| capture_output=True | ||
| ) | ||
|
|
||
| if result.returncode == 0 and os.path.exists(temp_output_png): | ||
| # Get caption from filename | ||
| caption = msc_basename.replace("-", " ").replace("_", " ") | ||
|
|
||
| # If output_directory is specified, copy the image there | ||
| if abs_output_dir and os.path.exists(abs_output_dir): | ||
| import shutil | ||
| dest_path = os.path.join(abs_output_dir, output_png) | ||
| shutil.copy2(temp_output_png, dest_path) | ||
| # Clean up temporary file if it's not in output directory | ||
| if os.path.abspath(temp_output_png) != dest_path: | ||
| os.remove(temp_output_png) | ||
| # Use only the filename (no path) for markdown reference | ||
| return (output_png, caption) | ||
| else: | ||
| # Use relative path from original working directory | ||
| abs_img_path = os.path.abspath(temp_output_png) | ||
| rel_path = os.path.relpath(abs_img_path, original_dir) | ||
| return (rel_path, caption) | ||
| else: | ||
| return None | ||
| except Exception as e: | ||
| return None | ||
|
|
||
| # Generate diagrams for all MSC files | ||
| msc_diagrams = [] | ||
| if interfaceview_xml: | ||
| for msc_file in msc_files: | ||
| result = generate_e2e_diagram(msc_file, interfaceview_xml) | ||
| if result: | ||
| msc_diagrams.append((msc_file, result[0], result[1])) | ||
|
|
||
| %> | ||
|
|
||
| This section presents end-to-end (E2E) messaging sequence diagrams generated from MSC (Message Sequence Chart) files. | ||
|
|
||
| % if not interfaceview_xml: | ||
| *Interface View XML file not found. Cannot generate E2E diagrams.* | ||
| % elif not msc_files: | ||
| *No MSC files found in the project directory.* | ||
| % else: | ||
| ## E2E Sequence Diagrams | ||
|
|
||
| The following E2E sequence diagrams have been generated from MSC files: | ||
|
|
||
| % for (msc_file, img_path, caption) in msc_diagrams: | ||
| ${"###"} ${caption.title()} | ||
|
|
||
| **Source:** `${msc_file}` | ||
|
|
||
|  | ||
|
|
||
| % endfor | ||
|
|
||
| % if len(msc_diagrams) < len(msc_files): | ||
| *Note: ${len(msc_files) - len(msc_diagrams)} MSC file(s) could not be processed. Ensure SpaceCreator is available and the MSC files are valid.* | ||
| % endif | ||
| % endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #!/bin/bash | ||
|
|
||
| cd demo-project | ||
| mkdir -p ../output | ||
|
|
||
| # Generate MD E2E documentation | ||
| template-processor --verbosity info \ | ||
| --iv interfaceview.xml \ | ||
| -o ../output \ | ||
| -t ../e2e-demo.tmplt | ||
|
|
||
| # Generate DOCX version | ||
| template-processor --verbosity info \ | ||
| --iv interfaceview.xml \ | ||
| -o ../output \ | ||
| -t ../e2e-demo.tmplt \ | ||
| -p md2docx |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.