Descriptive plaintext within a class

0 votes
asked May 27, 2017 in Wanted features by anonymous
Thanks for this great tool!

I am now using this tool for UML diagrams to understand the codes of a project. I use the Class diagram to classify the relationships/functions of the classes. Sometimes I want to add notes about the class, its members, and its methods. Using existing plantUML's notes will make the diagram messy. So I want to add them right into the class rectangle, just like comments in our code. Is that possible?

 

That is, I want the class diagram to be something like this:

 

--------------------------

    DummyClass

--------------------------

- string id

- int index

// This is the name of the DummyClass

// This descriptive text should be displayed in grey

- string name

--------------------------

+void func()

-------------------------

 

Thanks very much!

1 Answer

0 votes
answered May 29, 2017 by plantuml (183,480 points)
 
Best answer

This is not perfect, but you can use the preprocessor to do so.
Example:

@startuml
!define COMMENT(x) <color:grey>x</color>
class DummyClass {
- string id
- int index
COMMENT(This is the name of the DummyClass)
COMMENT(This descriptive text should be displayed in grey)
- string name
}
@enduml



Tell us if it's working for you!
 

commented May 31, 2017 by anonymous
edited May 31, 2017
That's great! However, if there is only one method in the class, the comment will be treated as member.

Example:

@startuml
!define COMMENT(x) <color:grey>x</color>
interface A {
    COMMENT(Callback when update finished.)
    + {abstract} updateFinished()
}
@enduml

http://www.plantuml.com/plantuml/uml/SoWkIImgAStDuL9CIKtBp4jLSFRtzNNr2z6eq5ImISxFoI-oIYzAhRIhiD47y-ouClDAKelI4fDJ5HmLghaKW02cnJan9oSfCJbReJmZDK-Xj20biIHL0MXePd56QegU9bYjja9rOb9nIL5YSaajL8aRL8M69bSjbqDgNWhGEG00

A workaround is to manually set the layout of the class with `--`.
commented May 31, 2017 by plantuml (183,480 points)
In that case, you can also have:
@startuml
!define COMMENT(x) <color:grey>x</color>
interface A {
    {method} COMMENT(Callback when update finished.)
    + {abstract} updateFinished()
}
@enduml

http://www.plantuml.com/plantuml/uml/FOx12i8m44Jl-OhrrY3eNKgf57khNlo1RRArnJIHP8kLa7-tbkBS1juRfWoCdgVHY9scRh04rQrfBjTxDal8bJFEdnwUFiMS7zTMYC4o-GuLmHcYW2Ln9EwTJd-tGcDQL4zuzsHXUcbaWcLz23tfWrobFKHi0tjKd3QateXCYYHAilhtwmi0
commented Jun 1, 2017 by anonymous
Great! Do you have the manual for {method}? I can't find it in the Language Reference Guide. Is {field} for the data members?

Then it will be convenient to have two macros:
CM1(x) {method} <color:grey>x</color>
CM2(x) {field} <color:grey>x</color>

Thanks!
commented Jun 1, 2017 by plantuml (183,480 points)
Yes, it's {field} for the data members.
We have to update the doc...
...