Please support PHP namespace separator

0 votes
asked Jul 12, 2013 in Wanted features by anonymous
First - thanks for plantuml.  Started using it yesterday and able to generate drawings a lot faster than by any other method I found so far.  the Netbeans plugin is great.

So I am a PHP dev.  Namespaces in PHP use the backslash '\'.   I figured out how to do this for class names e.g.

class "\\Foo\\Type\\StringType"

but trying to set a namespaceSeparator doesn't work.  I tried

set namespaceSeparator "\\"

set namespaceSeparator "\\\\"

set namespaceSeparator \\

set namespaceSeparator \

All fail  either giving an error or not auto creating namespace packages as expected.  So can you add support for backslashes into your inevitably long list of 2Dos please.

1 Answer

0 votes
answered Jul 12, 2013 by plantuml (295,000 points)
Hello,

As usually, there are some tricks with the backslash...
First, as you have figurated it out, you have to double it.
Second, there is a not-very-documented feature in PlantUML that allows to split a line
into several lines, putting a \ at the end.
Example:
@startuml
Alice -> Bob : this comment \
is on a line
@enduml
http://www.plantuml.com:80/plantuml/img/Syp9J4vLqBLJSCfFKh1IACd8B5P8pi_DJSqhKOZX0dBoynGI5N8oyr81

Unfortunalty, this is clashing with "set namespaceSeparator \\".
A possible turn-around is to put a white space after the \\: "set namespaceSeparator \\ "
This would prevent the line to be merged.

So finally, you can use:

@startuml
'put a whitespace after the \\ in the next line, otherwhise the line will be merged with the next one
set namespaceSeparator \\
class X1\\X2\\foo {
  some info
}
@enduml

http://www.plantuml.com/plantuml/img/HOqn3W8X54HxJZ6TZOrUnMOBckywAoJ09_3DcXZlBajZDsycatUgBuEWLra9sOmD5WZl4SjCXMz3YeLdwE2sXzWvbwF47bF2dSXiJpu6MlZVjD1r6efaJiEDLPgOjaFWrYIzOxbulroztrJnSK3Np27Vr7r_

We will fix the whitespace issue in the next release : lines ending with 2 backslashes will not be merged.

Regards, and happy UML
commented Nov 8, 2013 by anonymous
Hello,

Thank you also for PlantUML. I'm in the exact same case as the previous user, I used it since... 1 hour and I was quite happy to find this answer.

However, it seems that it does not work using the namespace declaration:

@startuml
set namespaceSeparator \\
namespace \\Foo\\Bar
    class MyClass
end namespace
@enduml

Is there any workaround or maybe am I doing it wrong?

Thanks for your help.
commented Feb 3, 2016 by anonymous
Hello,

If I use either of the examples beneath, it will not work:

set namespaceSeparator \\
class CustomerController extends App\\Http\\Controllers\\Controller {
     some info
}

@enduml

Or:

@startuml

set namespaceSeparator \\

CustomerController --|> App\\Http\\Controllers\\Controller

@enduml
commented Feb 3, 2016 by plantuml (295,000 points)
Thanks for the report.
This has been fixed in last beta https://dl.dropboxusercontent.com/u/13064071/plantuml.jar

Tell us if it's working for you.
Regards,
...