How to let PlantUML keep reading a .md document, which is keep updating, and update? Is this possible?

0 votes
asked Jul 23 in Question / help by CKS
Target is to generate a real-time sequential diagram, which is dynamical. One of the idea is try to let PlantUML keep reading a .md document, then keep updating. Is this possible? Do you have any more idea?

Thanks in advance, looking forward to hear from you : )

1 Answer

0 votes
answered Jul 25 by dragondive (1,360 points)
Rather than md files, I suggest reading in your data through a JSON file.

Here are some example codes for your reference:

1. https://github.com/dragondive/masadora/blob/b4fcccb10130b0d5a20325e6ea905fcee45c5c88/plantuml/production_controller_sequence.puml

2. https://github.com/dragondive/plantuml_demo/blob/main/src/preprocessor/README.rst#generate-multiple-customized-diagrams-from-diagram-template

Here is also a somewhat more "fun" example, that also has more complex JSON data structure: https://github.com/dragondive/plantuml_demo/blob/main/src/preprocessor/README.rst#compute-and-draw-test-cricket-matches-hosting-data-in-hierarchical-structure

As for updating the diagrams dynamically, as far as I know, PlantUML does not have such a facility to monitor files and update diagrams on the fly. Regardless of that, my suggestion would be to keep separate things separate. Do the dynamic updating outside PlantUML. For example, you could upload your JSON data file to Github (or GHE, at work), then setup a Github Actions workflow (or the equivalent tool you use) to trigger PlantUML at regular intervals. If "real time" data updates are important, you could also trigger the workflow whenever the JSON data file changes. [Note: replace Github/Github Actions with the equivalent tools you're using.]

I think you'll be able to figure out the rest. Please feel free to ask if you have more questions.
commented Jul 29 by anonymous
Thanks a lot for your suggestion! They are really good point!
commented Jul 30 by CKS
Hi, I would like to ask further. Why JSON is better, and why MD is not suitable? Thanks
commented Jul 30 by dragondive (1,360 points)
How will you update the PlantUML diagram based on MD files? Do you have a sample code or prototype for it?
...