Author Topic: PlantUML Support  (Read 2295 times)

TKasparek

  • Senior Community Member
  • Posts: 246
  • Hero Points: 29
PlantUML Support
« on: May 19, 2020, 05:24:13 PM »
There was another comment about PlantUML a few years ago:
https://community.slickedit.com/index.php/topic,15442.0.html

We use doxygen and implant plantuml in comments for explaining complicated architecture. It would be awesome to have the picture show up in a tool window for the area I'm editing. Even if the update is done via a macro invocation, each time it is invoked it would just update the picture (or update live on save or edits.)
I can make a macro that searches for the beginning/end tags and copy it to a file and have it generated. But I'm not sure how would I go about making the image show up in a new dockable tool window? (And ensure it is always the same windows and overwrites the current image?)

Code: [Select]
/**
@startuml{Marrage.png}
actor Alice
actor Bob
Alice -> Bob : Get off the couch!!
Bob -> Alice : Not until you make me a sammich!
@enduml
*/

It would be awesome to have this functionally in a well written macro. There are plug-ins available for many other editors that do this.
plantuml.com
planttext.com

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
Re: PlantUML Support
« Reply #1 on: May 19, 2020, 11:01:17 PM »
Since the tool can generate SVG, you can generate a small HTML wrapper that references the generated SVG image and you're halfway there.  You just need a tool window with an HTML control that you refresh when you want to.  The preview tool window might be the one to tweak, you can send the information along with the generated HTML comment to the Preview tool window.  That will require some tweaking.  Near the end of tagwin.e / DisplayFile(), use the comments already pulled together from there using _ExtractTagComments2(), check if it has the @startuml / @enduml, send that to the planttext engine, and just add the HTML <img> link to the generated SVG to the comment text.

I'll file an FR to improve our hook code to make it easier to plug in a comment processor like this.

TKasparek

  • Senior Community Member
  • Posts: 246
  • Hero Points: 29
Re: PlantUML Support
« Reply #2 on: November 18, 2020, 03:54:04 PM »
Hey Dennis, was there any movement on the FR you submitted for this? Am I able to subscribe somehow to updates on it? I'm thinking I'll have time around the holidays to look into your suggestions and would like to try to implement something.

Thanks,
Tom

Dennis

  • Senior Community Member
  • Posts: 3992
  • Hero Points: 520
Re: PlantUML Support
« Reply #3 on: November 18, 2020, 04:16:10 PM »
Try writing a language specific Slick-C callback of the following form:

Code: [Select]
int _<langid>_process_comments(_str &out_msg, VSCodeHelpCommentFlags comment_flags, _str in_msg);

This should return one of the following status:
  • status < 0 -- ignore 'out_msg', just use 'in_msg' as it is
  • status > 0 -- append 'out_msg' to formatted version of 'in_msg'
  • status == 0 -- use 'out_msg' as it was returned

For your case, you may need to cut out the UML portion (or go ahead and replace it with a <img> ref),
then format the rest of the comment using tag_tree_make_html_comment(),
as is done in _make_html_comments() and return '0' to take the whole thing.

Look at _make_html_comments, you'll see how it is all hooked together.
« Last Edit: November 18, 2020, 04:17:52 PM by Dennis »