Closed GeTOUO closed 5 years ago
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:
I did sign the CLA
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.
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.
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)
@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 = ""
}
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;
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.
there is an operation in the project that needs to read field annotations directly
can you explain that more? I don't understand.
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.
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.)
1.create field from case class 2.borrow comment from clz thank!