forked from lxm_tools/screw
♻️ 重构生成文档名称
This commit is contained in:
11
README.md
11
README.md
@@ -119,7 +119,9 @@ void documentGeneration() {
|
||||
//文件类型
|
||||
.fileType(EngineFileType.HTML)
|
||||
//生成模板实现
|
||||
.produceType(EngineTemplateType.freemarker).build();
|
||||
.produceType(EngineTemplateType.freemarker)
|
||||
//自定义文件名称
|
||||
.fileName("自定义文件名称").build();
|
||||
|
||||
//忽略表
|
||||
ArrayList<String> ignoreTableName = new ArrayList<>();
|
||||
@@ -157,8 +159,7 @@ void documentGeneration() {
|
||||
.engineConfig(engineConfig)
|
||||
//生成配置
|
||||
.produceConfig(processConfig)
|
||||
//自定义文档名称
|
||||
.docName(getDocName()).build();
|
||||
.build();
|
||||
//执行生成
|
||||
new DocumentationExecute(config).execute();
|
||||
}
|
||||
@@ -202,14 +203,14 @@ void documentGeneration() {
|
||||
<openOutputDir>false</openOutputDir>
|
||||
<!--生成模板-->
|
||||
<produceType>freemarker</produceType>
|
||||
<!--文档名称 为空时:将采用[数据库名称-描述-版本号]作为文档名称-->
|
||||
<fileName>测试文档名称</docName>
|
||||
<!--描述-->
|
||||
<description>数据库文档生成</description>
|
||||
<!--版本-->
|
||||
<version>${project.version}</version>
|
||||
<!--标题-->
|
||||
<title>数据库文档</title>
|
||||
<!--文档名称 为空时:将采用[dbName-description-version]作为文档名称-->
|
||||
<docName>测试文档名称</docName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -69,10 +69,6 @@ public class Configuration implements Serializable {
|
||||
* 引擎配置,关于数据库文档生成相关配置
|
||||
*/
|
||||
private EngineConfig engineConfig;
|
||||
/**
|
||||
* 自定义文档名称
|
||||
*/
|
||||
private String docName;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
@@ -84,11 +80,10 @@ public class Configuration implements Serializable {
|
||||
* @param dataSource {@link DataSource} 数据源
|
||||
* @param produceConfig {@link ProcessConfig} 生成配置
|
||||
* @param engineConfig {@link EngineConfig} 生成配置
|
||||
* @param docName {@link String} 自定义文档名称
|
||||
*/
|
||||
private Configuration(String organization, String organizationUrl, String title, String version,
|
||||
String description, DataSource dataSource, ProcessConfig produceConfig,
|
||||
EngineConfig engineConfig, String docName) {
|
||||
EngineConfig engineConfig) {
|
||||
Assert.notNull(dataSource, "DataSource can not be empty!");
|
||||
Assert.notNull(engineConfig, "EngineConfig can not be empty!");
|
||||
this.title = title;
|
||||
@@ -99,7 +94,6 @@ public class Configuration implements Serializable {
|
||||
this.dataSource = dataSource;
|
||||
this.engineConfig = engineConfig;
|
||||
this.produceConfig = produceConfig;
|
||||
this.docName = docName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +115,6 @@ public class Configuration implements Serializable {
|
||||
private DataSource dataSource;
|
||||
private ProcessConfig produceConfig;
|
||||
private EngineConfig engineConfig;
|
||||
private String docName;
|
||||
|
||||
ConfigurationBuilder() {
|
||||
}
|
||||
@@ -166,11 +159,6 @@ public class Configuration implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Configuration.ConfigurationBuilder docName(String docName) {
|
||||
this.docName = docName;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* build
|
||||
*
|
||||
@@ -179,7 +167,7 @@ public class Configuration implements Serializable {
|
||||
public Configuration build() {
|
||||
return new Configuration(this.organization, this.organizationUrl, this.title,
|
||||
this.version, this.description, this.dataSource, this.produceConfig,
|
||||
this.engineConfig, this.docName);
|
||||
this.engineConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,4 +51,8 @@ public class EngineConfig implements Serializable {
|
||||
* 自定义模板,模板需要和文件类型和使用模板的语法进行编写和处理,否则将会生成错误
|
||||
*/
|
||||
private String customTemplate;
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,9 @@ public abstract class AbstractExecute implements Execute {
|
||||
* @return {@link String} 名称
|
||||
*/
|
||||
String getDocName(String database) {
|
||||
if (StringUtils.isNotBlank(config.getDocName())) {
|
||||
return config.getDocName();
|
||||
//自定义文件名称不为空
|
||||
if (StringUtils.isNotBlank(config.getEngineConfig().getFileName())) {
|
||||
return config.getEngineConfig().getFileName();
|
||||
}
|
||||
//描述
|
||||
String description = config.getDescription();
|
||||
|
||||
@@ -167,10 +167,10 @@ public class RunDocMojo extends AbstractMojo {
|
||||
private String template;
|
||||
|
||||
/**
|
||||
* 自定义文档名称
|
||||
* 文件名称
|
||||
*/
|
||||
@Parameter
|
||||
private String docName;
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文档生成
|
||||
@@ -198,9 +198,7 @@ public class RunDocMojo extends AbstractMojo {
|
||||
//引擎模板配置
|
||||
.engineConfig(getEngineConfig())
|
||||
//数据处理配置
|
||||
.produceConfig(getProcessConfig())
|
||||
//自定义文档名称
|
||||
.docName(getDocName()).build();
|
||||
.produceConfig(getProcessConfig()).build();
|
||||
//生成文档
|
||||
new DocumentationExecute(config).execute();
|
||||
getLog().info(String.format(LOGGER_COMPLETE, (System.currentTimeMillis() - start) / 1000));
|
||||
@@ -222,7 +220,9 @@ public class RunDocMojo extends AbstractMojo {
|
||||
//生成模板实现
|
||||
.produceType(getProduceType())
|
||||
//自定义模板位置
|
||||
.customTemplate(getTemplate()).build();
|
||||
.customTemplate(getTemplate())
|
||||
//文件名称
|
||||
.fileName(getFileName()).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user