Enum values output without separator
baboy opened this issue · comments
Your Environment(您的使用环境)
- smart-doc version: 3.0.2
- plugin version (e.g. smart-doc-maven-plugin or smart-doc-gradle-plugin): 3.0.2
- build tool version(maven or gradle): maven
- jdk version: 17
Expected Behavior(您期望的结果)
public enum EnabledEnum {
/**
* 禁用
*/
DISABLED(0),
/**
* 可用
*/
ENABLED(1);
private final int code;
EnabledEnum(int code) {
this.code = code;
}
public int getCode() {
return code;
}
}
Didn't set dataDictionaries field in smart-doc.json config file
I want the plugin output:
Field | Type | Description | Since |
---|---|---|---|
... | ... | - | |
└─status | enum | [Enum:DISABLED,ENABLED] | - |
Current Behavior(当前结果)
Field | Type | Description | Since |
---|---|---|---|
... | ... | - | |
└─status | enum | [Enum values:DISABLEDENABLED] | - |
-
If I didn't configure dataDictionaries in smart-doc.json,the Enum values display without separators,it's difficult to read.
-
If I configured dataDictionaries,doc will show "Enum:xxx", If I didn't configured the attribution,it will show Enum Values:xxx, the template is different...
-
if the class is original Enum, it didn't had code and desc fields, the plugin will be error:
eg:
public enum TestEnum {
NAME1,
NAME2;
}
smart-doc.json
{
"title": "测试",
"enumClassName": "xxx.TestEnum",
"codeField": "",
"descField": ""
}
[ERROR]
java.lang.RuntimeException: xxx.TestEnum:Please specify the code field name of the dictionary enumeration class and the field name that describes the dictionary code information
at com.power.common.util.EnumUtil.getEnumInformation (EnumUtil.java:37)
at com.ly.doc.utils.DocUtil.buildDictionary (DocUtil.java:1036)
at com.ly.doc.builder.DocBuilderTemplate.buildAllRenderDocTemplate (DocBuilderTemplate.java:161)
at com.ly.doc.builder.DocBuilderTemplate.buildDoc (DocBuilderTemplate.java:206)
at com.ly.doc.builder.DocBuilderTemplate.buildAllInOne (DocBuilderTemplate.java:122)
at com.ly.doc.builder.HtmlApiDocBuilder.buildApiDoc (HtmlApiDocBuilder.java:91)
at com.ly.doc.plugin.mojo.HtmlMojo.executeMojo (HtmlMojo.java:48)
at com.ly.doc.plugin.mojo.BaseDocsGeneratorMojo.execute (BaseDocsGeneratorMojo.java:168)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:568)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:283)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
at org.codehaus.classworlds.Launcher.main (Launcher.java:47)
I hope this plugin can compatible with the original Java Enum. and when I export dictionaries, it would display the NAME attribution of the Enum class. the name attribution is very important for Enum class.
Possible Solution(bug解决建议)
Steps to Reproduce (Bug产生步骤,请尽量提供用例代码)
Context(Bug影响描述)
I don't see the enumClassName parameter in smart-doc 3.0.2. Can't reproduce the exception, can you provide the code that reproduces it, the config file?
I don't see the enumClassName parameter in smart-doc 3.0.2. Can't reproduce the exception, can you provide the code that reproduces it, the config file?
If you define a Enum class in your project like this:
public enum TestEnum {
NAME1,
NAME2;
}
the Enum class without code and message attributions;
And you configure a dataDictionaries in smart-doc.json, like this:
{
"outPath": "D://docs/cloud-ability-api",
"sortByTitle": false,
"allInOne": true,
"allInOneDocFileName": "index.html",
"coverOld": true,
"inlineEnum": true,
...
"dataDictionaries": [
{
"title": "主机操作",
"enumClassName": "xxx.TestEnum",
"codeField": "",
"descField": ""
}
...
]
}
The exception will be output...
codeField 和 descField 不能为空,你可以使用toString():
"dataDictionaries": [
{
"title": "主机操作",
"enumClassName": "xxx.TestEnum",
"codeField": "toString()",
"descField": "toString()"
}
]
codeField 和 descField 不能为空,你可以使用toString():
"dataDictionaries": [ { "title": "主机操作", "enumClassName": "xxx.TestEnum", "codeField": "toString()", "descField": "toString()" } ]
@abing22333 嗯嗯,这个办法可以