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

生成的字段加上注释 #4

Open
karymay opened this issue Apr 30, 2024 · 5 comments
Open

生成的字段加上注释 #4

karymay opened this issue Apr 30, 2024 · 5 comments

Comments

@karymay
Copy link

karymay commented Apr 30, 2024

能否生成的字段加上注释,这样类似smart-doc这样的插件可以生成api文档。
public void printField(@nonnull PrintWriter writer, @nonnull Context context, String indent, int indentNum) {
Utils.printIndent(writer, indent, indentNum);
Utils.printComment(writer, comment, true, indent, indentNum);

@vipcxj
Copy link
Owner

vipcxj commented Apr 30, 2024

你说的注释还是注解?注释有继承机制,你原始类或者配置类上的注释会继承到生成类中(原始类可不可以其实有点记不清了,配置类肯定可以,因为我清楚记得我这么用过)
至于注解好像也能继承,记不太清了,如果不能那我原本应该也是有计划实现这个功能,后来可能嫌麻烦没搞。

@vipcxj
Copy link
Owner

vipcxj commented Apr 30, 2024

@karymay
example 看了下,注解确实是能继承的,不过需要配置一下

@karymay
Copy link
Author

karymay commented Apr 30, 2024

谢谢回复。 是指注释(不是注解,注解确实是能继承的)。
原始类字段上的的注释会拷贝到getter方法上面。但是smart-doc这样的只根据字段上的注释生成文档。

@vipcxj
Copy link
Owner

vipcxj commented Apr 30, 2024

这个必须拷贝到getter上,因为某些情况下,是不存在field,只有getter的 (比如在配置类内新加个字段,这种情况下写在配置类内的注释也是需要继承的,但显然不能放字段上),所以只能以getter为准。我没用过smart-doc,但我觉得应该不至于只能根据字段生成文档吧,就java来说getter的重要性很多时候高于field,一般库都是以getter为准的吧,所以或许你可以再查下smart-doc有没有什么配置选项可以以getter为准

@vipcxj
Copy link
Owner

vipcxj commented Apr 30, 2024

我这库支持插件,也就是接受beanknife解析的信息(里面包括bean的属性信息,属性信息中包括注释),自己生成代码,分为往生成的bean里塞代码和抛开这个bean,完全写到独立的文件里。我自己曾经利用这个机制写了个插件,自动生成mybait的crud的xml,所以应该没啥bug,因为bug都在那个时间都修的差不多了~

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

No branches or pull requests

2 participants