plantuml / plantuml

Generate diagrams from textual description
https://plantuml.com
Other
9.73k stars 881 forks source link

feature: random() function -- with a way to pick a number between X & Y #1667

Closed philCryoport closed 3 months ago

philCryoport commented 3 months ago

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like My intended use is for MQTT Packet Identifiers in a sequence diagram.

Brief overview of MQTT Packet Identifiers:

Now in a sequence diagram where I'm highlighting particular requests made by a MQTT Client to the MQTT Broker in the diagram, I could illustrate the use of these MQTT Packet Identifiers by just incrementing the packet identifer by 1, 10, or 100 -- using higher increment quantities to illustrate that there were requests sent in-between the actual particularly highlighted requests.

I thought it would be more realistic to instead increment the MQTT Packet Identifier number by a random value -- say between 101 and 499.

Hence this request for a random() function of some sort where I could have PlantUML (semi) randomly pick a number between X & Y (in this case, between 101 and 499)

Describe alternatives you've considered In theory I could hit one of the random number generator websites on the web each time I want to increment the MQTT Packet Identifier. However, my concern is that the generator website then becomes a dependency for which I have no control.

Additional context Originally discussed in PlantUML Discord

arnaudroques commented 3 months ago

Hi! Implementing a random function in some software that generates documentation seems completely crazy, so I like the idea. :-)

This should be easy to do.

I propose that %random(5) would return an integer between 0 and 4. Note that this function will not be safe for cryptographic usage... Does it match your need ?

arnaudroques commented 3 months ago

So you can try this for example.

philCryoport commented 3 months ago

@The-Lum @arnaudroques given your already-merged PRs, should we close this issue?