plantuml / plantuml

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

Feature Request: Add heredoc / nowdoc string variable assignment syntax #1671

Closed philCryoport closed 2 weeks ago

philCryoport commented 3 months ago

Is your feature request related to a problem? Please describe. As of this writing, string-variable assignment is single-line text between two double-quote (") characters. You want multi-line output? Insert new-line (\n) characters.

Makes it very difficult to read the code when it has multi-line strings...

Example:

!$poem = "Whose woods these are I think I know. \n His house is in the village though; \n He will not see me stopping here \n To watch his woods fill up with snow. "

Describe the solution you'd like Additionally allow the use of Heredoc / Nowdoc syntax with string-variable assignment.

Example:

!$poem = <<<EOT
Whose woods these are I think I know.   
His house is in the village though;   
He will not see me stopping here   
To watch his woods fill up with snow.   
EOT

Describe alternatives you've considered I'm not sure if there any alternatives...

Additional context N/A

The-Lum commented 3 months ago

Hi @philCryoport,

From:

@startuml
!$poem = "Whose woods these are I think I know. \n His house is in the village though; \n He will not see me stopping here \n To watch his woods fill up with snow. "
node "$poem" as n
@enduml

Here is temporary workaround using \n\ with the line continuation \, as:

@startuml
!$poem = "\
Whose woods these are I think I know. \n\
His house is in the village though; \n\
He will not see me stopping here \n\
To watch his woods fill up with snow."
node "$poem" as n
@enduml


:trollface: [Off topic] Even if (in python):

Enjoy, Regards, Th.

philCryoport commented 3 months ago

Hi @The-Lum I can work with \ as a line-continuation character.

Does the project team want to permanently preserve that workaround? Please let me know and I'll go find the online docs and submit a request to add this.

:trollface: [Off topic] Even if (in python):

* [reddit.com/r/learnpython/comments/mnubp4/is_it_bad_practice_to_use_backslash_line](https://www.reddit.com/r/learnpython/comments/mnubp4/is_it_bad_practice_to_use_backslash_line/)

Fascinating.

I've only coded a small amount of Python up until now (mostly PHP, Java, and SQL when I used to code full-time -- with a smattering of jQuery, ReactJS, Ruby, Scala, C, and bash scripting).

Looks like Python 3.10 wants to switch people over to surrounding groups of lines with parentheses, ending to-be-continued lines with commas.

arnaudroques commented 3 months ago

Does the project team want to permanently preserve that workaround?

No! :-)

Historically, the development and implementation of multiline management within PlantUML have proceeded without a comprehensive strategic framework or detailed specification. Changes and enhancements have been implemented in an ad hoc manner, based on immediate requirements and community feedback.

We have started a new specification document here http://alphadoc.plantuml.com/doc/markdown/en/spec-multiline Anyone can contribute (it's completely open, no password).

The idea is to get a proper idea of what we should do now about those \ and \n. My personal opinion is that we should stop using it: I think it was a bad idea. However, we have to use something instead... but what exactly?

Feel free to write your ideas and suggestions!

philCryoport commented 3 months ago

We have started a new specification document here http://alphadoc.plantuml.com/doc/markdown/en/spec-multiline Anyone can contribute (it's completely open, no password).

😳

Might I suggest a different method -- perhaps with Markdown files in a Github repo -- so that changes are proposed, reviewed, then merged?

(just because I'm paranoid doesn't mean they're not out to get me / trash your alphadoc)

Maybe adopt a similar model to how OWASP does documentation?