Please provide a way to add notes to methods with parameters / return values

0 votes
asked Mar 30, 2017 in Closed feature request by pihentagy (180 points)

I'd like to attach a note to the following field/method:

@startuml
class A {
    {static} int counter
    +void {abstract} start(int timeout)
}
@enduml
commented Mar 31, 2017 by Serge Wenger Work (15,620 points)
It would be nice to be able to use the "as" syntax for methods and fields:

class "AAAAAAAAAA"  as A {

"{static} int counter" as StaticCounter

"+void {abstract} start(int timeout)" as start
}

after this we can do
note left of A::start
  Yet **another**
  note on several lines.
end note

1 Answer

0 votes
answered Mar 31, 2017 by plantuml (295,000 points)
selected Mar 23, 2018 by Anthony-Gaudino
 
Best answer

We fix this in last beta (beta17):
https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0

You can now have:

@startuml
class A {
{static} int counter
+void {abstract} start(int timeout)
}
note right of A::counter
  This member is annotated
end note
note right of A::start
  This method is now explained in a UML note
end note

@enduml


 

commented Mar 31, 2017 by Serge Wenger Work (15,620 points)
Hello,
It is working with your example, but it is not working to explain the difference of 2 functions with the same name:

@startuml
class A {
{static} int counter
+void {abstract} start(int timeoutms)
+void {abstract} start(Duration timeout)
}
note right of A::counter
  This member is annotated
end note
note right of A::start
  This method with int
end note
note right of A::start
  This method with Duration
end note
@enduml
commented Mar 31, 2017 by plantuml (295,000 points)
By chance, there is a way with your example:

@startuml
class A {
{static} int counter
+void {abstract} start(int timeoutms)
+void {abstract} start(Duration timeout)
}
note right of A::counter
  This member is annotated
end note
note right of A::start(int
  This method with int
end note
note right of A::start(Duration
  This method with Duration
end note
@enduml

There cannot be space after :: so this won't work in many case.
We don't like "as" keyword proposal (sorry about that) because today PlantUML does not really try to parse the class body itself (that is member/fields/methods...)
We can implement some wildcard option, so that people would be able to use:
note right of A::start*timeoutms
Or we could allows space after :: (with quotes).
Not sure which is best.
commented Mar 31, 2017 by Serge Wenger Work (15,620 points)
Thanks. I understand your point of view. It is OK for method, but not field.
For me A::"string with spaces " is better than  A::start*timeoutms, because in c * is used for pointer.
One other possibility is to encode the text without space like html.

@startuml
class A {
{static} int counter
double counter
+void {abstract} start(int timeoutms)
+void {abstract} start(Duration timeout)
}
note right of A::counter
  This member is annotated
end note
note right of A::start(int
  This method with int
end note
'Proposal
note right of A::"double counter"
  second counter
end note
'or
note right of A::double counter
  second counter
end note

@enduml
commented Mar 31, 2017 by plantuml (295,000 points)
Ok, with last beta (beta18)
https://www.dropbox.com/s/koo42q3d9gxw288/plantuml.jar?dl=0
You can now have
@startuml
class A {
{static} int counter
+void {abstract} start(int timeoutms)
+void {abstract} start(Duration timeout)
}
note left of A::counter
  This member is annotated
end note
note right of A::"start(int timeoutms)"
  This method with int
end note
note right of A::"start(Duration timeout)"
  This method with Duration
end note
@enduml
commented Apr 3, 2017 by Serge Wenger Work (15,620 points)
Thanks, it is perfect for me
commented May 29, 2020 by foodtooth (100 points)
This is not working if you've defined the class in a namespace
...