Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add class and field comments to entity generator #1952

Conversation

andidev
Copy link
Member

@andidev andidev commented Aug 29, 2015

@andidev
Copy link
Member Author

andidev commented Aug 29, 2015

{
    "relationships": [
        {
            "relationshipId": 1,
            "relationshipName": "complexJavadocRelationship",
            "otherEntityName": "complexJavadocRelationship",
            "relationshipType": "one-to-many",
            "otherEntityRelationshipName": "complexJavadocEntity",
            "javadoc": "<p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. &#47;* Fames odio quam. *&#47;</p><p>TODO:</p>\n\n<ul>\n<li>first &uuml;ber</li>\n<li>second</li>\n</ul>\n\nMake sure that json special characters like double quotes \" and backslashes \\ are escaped in json file and correctly displayed in javadoc"
        }
    ],
    "fields": [
        {
            "fieldId": 1,
            "fieldName": "complexJavadocField",
            "fieldType": "String",
            "javadoc": "<p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. &#47;* Fames odio quam. *&#47;</p><p>TODO:</p>\n\n<ul>\n<li>first &uuml;ber</li>\n<li>second</li>\n</ul>\n\nMake sure that json special characters like double quotes \" and backslashes \\ are escaped in json file and correctly displayed in javadoc"
        }
    ],
    "changelogDate": "20150829194644",
    "dto": "no",
    "pagination": "no",
    "javadoc": "<p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. &#47;* Fames odio quam. *&#47;</p><p>TODO:</p>\n\n<ul>\n<li>first &uuml;ber</li>\n<li>second</li>\n</ul>\n\nMake sure that json special characters like double quotes \" and backslashes \\ are escaped in json file and correctly displayed in javadoc"
}

will generate

/**
 * <p>This class represents the Magna ligula pellentesque. Lacus ut sed.
 * Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent
 * metus. &#47;* Fames odio quam. *&#47;</p><p>TODO:</p>
 * 
 * <ul>
 * <li>first &uuml;ber</li>
 * <li>second</li>
 * </ul>
 * 
 * Make sure that json special characters like double quotes " and backslashes
 * \ are escaped in json file and correctly displayd in javadoc
 */
@Entity
@Table(name = "COMPLEXJAVADOCENTITY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class ComplexJavadocEntity implements Serializable {

    ...

    /**
     * <p>This class represents the Magna ligula pellentesque. Lacus ut sed.
     * Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent
     * metus. &#47;* Fames odio quam. *&#47;</p><p>TODO:</p>
     * 
     * <ul>
     * <li>first &uuml;ber</li>
     * <li>second</li>
     * </ul>
     * 
     * Make sure that json special characters like double quotes " and
     * backslashes \ are escaped in json file and correctly displayd in javadoc
     */  
    @Column(name = "complex_javadoc_field")
    private String complexJavadocField;

    /**
     * <p>This class represents the Magna ligula pellentesque. Lacus ut sed.
     * Himenaeos litora et posuere. Accumsan purus inceptos. Ultricies praesent
     * metus. &#47;* Fames odio quam. *&#47;</p><p>TODO:</p>
     * 
     * <ul>
     * <li>first &uuml;ber</li>
     * <li>second</li>
     * </ul>
     * 
     * Make sure that json special characters like double quotes " and
     * backslashes \ are escaped in json file and correctly displayd in javadoc
     */
    @OneToMany(mappedBy = "complexJavadocEntity")
    @JsonIgnore
    @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
    private Set<ComplexJavadocRelationship> complexJavadocRelationships = new HashSet<>();

    ...

}

@deepu105
Copy link
Member

Awesome and they are optional right? May be we can add another quest in
entity generator to capture this from user as optional input as well what
say?
On 30 Aug 2015 04:04, "Anders Steiner" notifications@github.com wrote:

{
"relationships": [
{
"relationshipId": 1,
"relationshipName": "complexJavadocRelationship",
"otherEntityName": "complexJavadocRelationship",
"relationshipType": "one-to-many",
"otherEntityRelationshipName": "complexJavadocEntity",
"javadoc": "

This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos\nlitora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /\nFames odio quam. */

TODO:

\n\n
    \n
  • first über
  • \n
  • second
  • \n
\n\nMake sure that json special characters like double quotes " and backslashes \ are escaped in json file and correctly displayd in javadoc"
}
],
"fields": [
{
"fieldId": 1,
"fieldName": "complexJavadocField",
"fieldType": "String",
"javadoc": "

This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos\nlitora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /\nFames odio quam. /

TODO:

\n\n
    \n
  • first über
  • \n
  • second
  • \n
\n\nMake sure that json special characters like double quotes " and backslashes \ are escaped in json file and correctly displayd in javadoc"
}
],
"changelogDate": "20150829194644",
"dto": "no",
"pagination": "no",
"javadoc": "

This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos\nlitora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /\nFames odio quam. */

TODO:

\n\n
    \n
  • first über
  • \n
  • second
  • \n
\n\nMake sure that json special characters like double quotes " and backslashes \ are escaped in json file and correctly displayd in javadoc"
}

will generate

/** *

This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos * litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. /* * Fames odio quam. */

TODO:

* *
    *
  • first über
  • *
  • second
  • *
* * Make sure that json special characters like double quotes " and backslashes \ are escaped in json file and correctly displayd in javadoc */
@entity
@table(name = "COMPLEXJAVADOCENTITY")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)public class ComplexJavadocEntity implements Serializable {

...

/**     * <p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos     * litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. &#47;*     * Fames odio quam. *&#47;</p><p>TODO:</p>     *      * <ul>     * <li>first &uuml;ber</li>     * <li>second</li>     * </ul>     *      * Make sure that json special characters like double quotes " and backslashes \ are escaped in json file and correctly displayd in javadoc     */
@Column(name = "complex_javadoc_field")
private String complexJavadocField;

/**     * <p>This class represents the Magna ligula pellentesque. Lacus ut sed. Himenaeos     * litora et posuere. Accumsan purus inceptos. Ultricies praesent metus. &#47;*     * Fames odio quam. *&#47;</p><p>TODO:</p>     *      * <ul>     * <li>first &uuml;ber</li>     * <li>second</li>     * </ul>     *      * Make sure that json special characters like double quotes " and backslashes \ are escaped in json file and correctly displayd in javadoc     */
@OneToMany(mappedBy = "complexJavadocEntity")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<ComplexJavadocRelationship> complexJavadocRelationships = new HashSet<>();

...

}


Reply to this email directly or view it on GitHub
#1952 (comment)
.

@andidev
Copy link
Member Author

andidev commented Aug 30, 2015

It's fine by me. What do you sat @jdubois? This will lead to a lot more questioning but that is maybe no issue.

@andidev
Copy link
Member Author

andidev commented Aug 30, 2015

Added wordwrap on javadoc comment. It wraps att 80 characters. Not sure what the standard wordwrap is used for jhipster. @jdubois you have any input on this?

@jdubois
Copy link
Member

jdubois commented Aug 30, 2015

@andidev I don't want to have all those added questions, it's just going to be annoying most of the time. My opinion is that the class and field names should be clear enough, so that documenting them is useless (most of the time). I also believe clean coding names are the best documentation.
For the line length, the policy is to follow Intellij IDEA rules, but to be honnest I'm not sure what they are here!

@andidev
Copy link
Member Author

andidev commented Aug 30, 2015

Okey I have a look at intellijs default setting.

@jdubois
Are you okey with adding this feature at least for the jhipster uml (without questions asked by the generator)? I actually agree with you but that comments should not be needed but in complex systems they sometime could help.

@jdubois
Copy link
Member

jdubois commented Aug 31, 2015

@andidev yes this would only be for JHipster UML, as it makes sense in this case to have the comments coming from the UML tool (this is in fact something I've done in the past, when I was using ArgoUML, probably around 2000 or 2001...)

@cbornet
Copy link
Member

cbornet commented Sep 1, 2015

It would also be great to have these comments fill the swagger doc.

@andidev
Copy link
Member Author

andidev commented Sep 1, 2015

@cbornet unfortunately I have no swagger skills 😢
Could you hint me where the comments should be added so that swagger shows them?

@cbornet
Copy link
Member

cbornet commented Sep 1, 2015

@andidev You can use @ApiModel on the class and @ApiModelProperty on the attributes https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X#apimodel
Not sure how swagger-ui will react to html text though...

@andidev
Copy link
Member Author

andidev commented Sep 26, 2015

Did not find a way to deal with swagger.

Jhipster UML seems to be done with their work on their side. We should either merge this or close this PR. Are there any doubts on merging this @jdubois?

@andidev andidev force-pushed the add-class-and-field-comments-to-entity-generator branch from 3a4f2fe to e16a911 Compare September 26, 2015 18:46
@andidev andidev force-pushed the add-class-and-field-comments-to-entity-generator branch from e16a911 to 26d5dd1 Compare September 26, 2015 18:51
@andidev
Copy link
Member Author

andidev commented Sep 26, 2015

Fixed merge conflict so it should be mergable now

jdubois added a commit that referenced this pull request Oct 3, 2015
…-entity-generator

add class and field comments to entity generator
@jdubois jdubois merged commit 5702369 into jhipster:master Oct 3, 2015
@jdubois jdubois modified the milestone: Untracked PRs Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Class and Field javadoc comments to entity generator
4 participants