-
-
Notifications
You must be signed in to change notification settings - Fork 99
Transfer UML attribute or class comments to source code of generated entities #46
Comments
Hi! That's a pretty good idea! But that's the good part =). Let's have the input of the JHipster 6 @jdubois, @andidev, @deepu105, @gmarziou, @atomfrede, @gzsombor on this, but you have my "+1". |
We can have the comment text as an optional parameter for the json and that
|
@deepu105 suggestion gives a minimal impact on the generator so I say this is doable if wanted. |
@andidev Regarding the question if this feature is wanted enough: I think it would be a very useful feature and I would definitely use it. However I have no idea, how the majority of the jhipster-uml users utilize the software and whether it would support their workflow. Regarding the implementation: class comments appear directly within the packagedElement class, an example produced by Modelio 3.3 looks like: <packagedElement xmi:type="uml:Class" xmi:id="_lZ6hZkyUEeWd98JY82OrEw" name="MyCoolClass">
<ownedComment xmi:type="uml:Comment" xmi:id="_lZ6hZ0yUEeWd98JY82OrEw">
<body><p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /* Fames odio quam. */</p><p>TODO:</p>
<ul>
<li>first &uuml;ber</li>
<li>second</li>
</ul>
</body>
</ownedComment>
</packagedElement> The body element contains plain html, which could be used as class comment without much modification (xml entity decoding assumed): /**
* <p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /* Fames odio quam. */</p><p>TODO:</p>
*
* <ul>
* <li>first über</li>
* <li>second</li>
* </ul>
*/
@Entity
@Table(name = "MYCOOLCLASS")
public class MyCoolClass { New lines should be prefixed with " * " for nicer code layout and "*/" or in general slashes should be escaped using corresponding entity (/). Since line breaking is recommended (http://www.oracle.com/technetwork/articles/java/index-137868.html), due to html being insensitive to line feeds, a simple word wrap algorithm could be used: /**
* <p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos
* litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /*
* Fames odio quam. */</p><p>TODO:</p>
*
* <ul>
* <li>first über</li>
* <li>second</li>
* </ul>
*/ Attribute comments appear within <ownedAttribute> elements and should probably be transferred as a comment of the field declaration. Generally I suppose the same rules would apply. Maybe, since Modelio puts even on liners within <p> elements, stripping of enclosing paragraph elements might be a good idea? |
@mkresse yes, parsing the comments from modelio XMI files seems easy, but don't forget the others! |
So jhipster support for javadoc comments is ready to be merged! see PR jhipster/generator-jhipster#1952 for an example of how the json should look like and what will be generated. |
Ok! It should be ready next week in JHipster-UML (I hope so anyway, if we have time). |
Wow, this looks really great - can't wait to try it out. Thanks a lot for your work. |
Closing this thread as the comment support has been added to JHipster-UML, the documentation will soon be updated too. |
Hi there,
the XMI format allows the definition of comments for classes or attributes (via the <ownedComment> element). When using the jhipster-uml generator, it would be great if the generator would recognize such comments and include them as javadoc comment in the generated entity class.
This way, the UML model could be used not only as model for the generator, but also as documentation of the entity model.
The text was updated successfully, but these errors were encountered: