bafolts / plantcode

Provides a javascript utility to generate code in various languages given a plantuml class diagram.
https://segmentationfaults.com/plantcode
MIT License
217 stars 42 forks source link

Add support for plantuml notes #9

Closed noamtamim closed 8 years ago

noamtamim commented 8 years ago

In plantuml class diagram there are two ways to provide documentation/comments: notes and free text inside the class body. As plantcode is very strict about the grammar, it doesn't allow the puml source to have them.

Copying the docs to the code is a nice to have -- for the purpose of the issue, just ignoring them would be ok.

bafolts commented 8 years ago

Can you provide an example of the puml source that fails to execute? That way I can fix your case and add your case to the integration tests.

noamtamim commented 8 years ago

This is from plantuml's samples:

@startuml
class User {
  .. Simple Getter ..
  + getName()
  + getAddress()
  .. Some setter ..
  + setName()
  __ private data __
  int age
  -- encrypted --
  String password
}

@enduml

And so is this:

@startuml
class Object << general >>
Object <|--- ArrayList

note top of Object : In java, every class\nextends this one.

note "This is a floating note" as N1
note "This note is connected\nto several objects." as N2
Object .. N2
N2 .. ArrayList

class Foo
note left: On last defined class

@enduml
bafolts commented 8 years ago

I added the first example to the tests file and updated the grammar to parse it properly.

https://github.com/bafolts/plantuml-code-generator/blob/0e4eeb9181504a3ee8243bc2f74c933ed80c272a/tests/comments-dots.pegjs

Will get to the notes one soon.

noamtamim commented 8 years ago

Thank you very much for the quick response (and action!). I will test it soon with my real class diagram.

bafolts commented 8 years ago

I added support for the notes file you provided and added it as a test. I will close this issue time being. If you find any more issues feel free to post the sample input file.

https://github.com/bafolts/plantuml-code-generator/blob/master/tests/notes-file.pegjs