Skip to content

Conversation

@GeTOUO
Copy link

@GeTOUO GeTOUO commented Jul 25, 2019

1.create field from case class
2.borrow comment from clz
thank!

2.borrow comment from clz
@lightbend-cla-validator
Copy link
Collaborator

Hi @GeTOUO,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@GeTOUO
Copy link
Author

GeTOUO commented Jul 25, 2019

I did sign the CLA

@SethTisue
Copy link
Contributor

#186 fixes CI; if you rebase onto latest master, you'll get the fix here too.

@GeTOUO
Copy link
Author

GeTOUO commented Jul 25, 2019

Hello, can I merge these? Or do I need to do something else? This is the first time I submit code to an open source project. Please give me some advice. Thank you.

@raboof
Copy link
Contributor

raboof commented Jul 25, 2019

Hello, can I merge these?

You can either merge master into this branch, or rebase this branch on top of master (and force-push).

This is the first time I submit code to an open source project.

Cool, welcome! The code looks high-quality at first glance, though a testcase highlighting the intended effect might make it a little clearer what exactly is the intent behind it.

@SethTisue
Copy link
Contributor

the merge went fine, so CI is now able to run, but it's failing with many errors of the form:

[info] Test com.typesafe.genjavadoc.StrictVisibilitySpec.compileSourcesAndGenerateExpectedOutput started
[error] Test com.typesafe.genjavadoc.StrictVisibilitySpec.compileSourcesAndGenerateExpectedOutput failed: java.lang.IllegalArgumentException: requirement failed: <noprefix>, took 2.37 sec
[error]     at scala.reflect.internal.Types$Type.memberInfo(Types.scala:682)
[error]     at com.typesafe.genjavadoc.AST$FieldInfo$.apply(AST.scala:226)
[error]     at com.typesafe.genjavadoc.BasicTransform$$anonfun$addField$1.apply(BasicTransform.scala:192)
[error]     at com.typesafe.genjavadoc.BasicTransform$$anonfun$addField$1.apply(BasicTransform.scala:168)
[error]     at scala.Option.map(Option.scala:146)
[error]     at com.typesafe.genjavadoc.BasicTransform$class.addField(BasicTransform.scala:168)

@GeTOUO
Copy link
Author

GeTOUO commented Jul 26, 2019

@raboof @SethTisue thank you for your guidance.
The code I submitted contains the following optional extensions:
For example:

/**
  * @param field desc
  */
case class Foo(val field: String) {
    /**
      * some desc
      */
    val hi: String = ""
}
  1. Provide the option createfields, The value is boolean type:
    Only when createfields = true, the code generation process generates val and var into fields, The following additional Java fields will be generated:
public String field = null;
/**
 * some desc
 */
public String hi = null;
  1. Provide the option borrowConstructorArgsComment, The value is boolean type:
    Only if createfields = true && borrowConstructorArgsComment = true, The following changes will occur:
/**
 * field desc
 */
public String field = null;
/**
 * some desc
 */
public String hi = null;

I'm not familiar with genjavadoc testing yet.

The reason I want to add the above functionality is that there is an operation in the project that needs to read field annotations directly. Thank you for your guidance.

@SethTisue
Copy link
Contributor

there is an operation in the project that needs to read field annotations directly

can you explain that more? I don't understand.

@GeTOUO
Copy link
Author

GeTOUO commented Aug 2, 2019

Details are as follows:
Suppose there is a case class:

/**
  * @param name fullname
  */
case class User(name: String) {val level = 1}

In my project, I need to extract the comment into a json(User.json):

{"comment":"","fields":{"name":{"comment":"fullname","tags":{}}, "level": {...}},"methods":{...}}

In my http interface definition:

@PostMapping(url = "/user")
def create(name: String): User {  //dosomthing }

The response data is User and User.json was found, I will fetch the accessible field generation API description document of the User class from User.json.

http: post /user,
request: name: String,

response:

field type desc
name string fullname
level Integer

The problem I am having now is that it looks like this:

This will output arg and field as method:

public String arg() {...}
public Integer level() {...}

But I hope to get

public String arg = null;
public Integer level= null;

So in my pr,
Turning on the option createField will generate more fields.

This involves some changes in functionality. If you think this is beyond the scope of genjavadoc, you can turn it off. Thank you.

@SethTisue
Copy link
Contributor

SethTisue commented Aug 2, 2019

Yeah, I'd be reluctant to accept a PR that isn't actually about improving Javadoc generation. It sounds to me like something you would be better off keeping in your own fork.

(Merging it might seem harmless, but: if we merge it, we would also need to maintain it afterwards, for years to come.)

@SethTisue SethTisue closed this Aug 2, 2019
@raboof raboof added this to the 0.14 milestone Sep 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants