support set project name
This commit is contained in:
parent
b6a82bbf6c
commit
fbbdb600dc
|
@ -55,6 +55,13 @@ public class ApiDocTest {
|
||||||
//Set the api document output path.
|
//Set the api document output path.
|
||||||
config.setOutPath("d:\\md");
|
config.setOutPath("d:\\md");
|
||||||
|
|
||||||
|
//since 1.7.5
|
||||||
|
//corverd old AllIneOne.md file generated by smart-doc.
|
||||||
|
config.setCoverOld(true);
|
||||||
|
|
||||||
|
//since 1.7.5
|
||||||
|
//set project name
|
||||||
|
config.setProjectName("Your project name");
|
||||||
// If you do not configure PackageFilters, it matches all controllers by default.
|
// If you do not configure PackageFilters, it matches all controllers by default.
|
||||||
// Configure multiple controller paths to be separated by commas
|
// Configure multiple controller paths to be separated by commas
|
||||||
config.setPackageFilters("com.power.doc.controller");
|
config.setPackageFilters("com.power.doc.controller");
|
||||||
|
@ -65,6 +72,7 @@ public class ApiDocTest {
|
||||||
.setDesc("Basic auth credentials").setRequired(true).setSince("v1.1.0"),
|
.setDesc("Basic auth credentials").setRequired(true).setSince("v1.1.0"),
|
||||||
ApiReqHeader.header().setName("user_uuid").setType("string").setDesc("User Uuid key")
|
ApiReqHeader.header().setName("user_uuid").setType("string").setDesc("User Uuid key")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//Output a list of error codes in the project, using for example:
|
//Output a list of error codes in the project, using for example:
|
||||||
List<ApiErrorCode> errorCodeList = new ArrayList<>();
|
List<ApiErrorCode> errorCodeList = new ArrayList<>();
|
||||||
|
|
|
@ -69,7 +69,12 @@ public class ApiDocTest {
|
||||||
// SourceCodePath.path().setDesc("本项目代码").setPath("src/main/java"),
|
// SourceCodePath.path().setDesc("本项目代码").setPath("src/main/java"),
|
||||||
SourceCodePath.path().setDesc("加载项目外代码").setPath("E:\\ApplicationPower\\ApplicationPower\\Common-util\\src\\main\\java")
|
SourceCodePath.path().setDesc("加载项目外代码").setPath("E:\\ApplicationPower\\ApplicationPower\\Common-util\\src\\main\\java")
|
||||||
);
|
);
|
||||||
|
//since 1.7.5
|
||||||
|
//如果该选项的值为false,则smart-doc生成allInOne.md文件的名称会自动添加版本号
|
||||||
|
config.setCoverOld(true);
|
||||||
|
//since 1.7.5
|
||||||
|
//设置项目名(非必须),如果不设置会导致在使用一些自动添加标题序号的工具显示的序号不正常
|
||||||
|
config.setProjectName("抢购系统");
|
||||||
//设置请求头,如果没有请求头,可以不用设置
|
//设置请求头,如果没有请求头,可以不用设置
|
||||||
config.setRequestHeaders(
|
config.setRequestHeaders(
|
||||||
ApiReqHeader.header().setName("access_token").setType("string").setDesc("Basic auth credentials"),
|
ApiReqHeader.header().setName("access_token").setType("string").setDesc("Basic auth credentials"),
|
||||||
|
|
|
@ -108,6 +108,8 @@
|
||||||
1. 优化文档中错误列表的标题,可根据语言环境变化显示中文或因为。
|
1. 优化文档中错误列表的标题,可根据语言环境变化显示中文或因为。
|
||||||
2. 解决项目外jar中内部类生成文档错误的bug。
|
2. 解决项目外jar中内部类生成文档错误的bug。
|
||||||
3. 支持环形依赖分析。只要你敢写!
|
3. 支持环形依赖分析。只要你敢写!
|
||||||
|
4. 修改使用SpringMvc或者SpringBoot上传时接口的Content-Type显示错误。
|
||||||
|
5. 支持设置项目作为markdown的一级标题。
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.power.doc.builder;
|
package com.power.doc.builder;
|
||||||
|
|
||||||
import com.power.common.util.DateTimeUtil;
|
import com.power.common.util.DateTimeUtil;
|
||||||
|
import com.power.common.util.StringUtil;
|
||||||
import com.power.doc.model.ApiConfig;
|
import com.power.doc.model.ApiConfig;
|
||||||
import com.power.doc.model.ApiDoc;
|
import com.power.doc.model.ApiDoc;
|
||||||
|
|
||||||
|
@ -29,8 +30,8 @@ public class ApiDocBuilder {
|
||||||
SourceBuilder sourceBuilder = new SourceBuilder(config);
|
SourceBuilder sourceBuilder = new SourceBuilder(config);
|
||||||
List<ApiDoc> apiDocList = sourceBuilder.getControllerApiData();
|
List<ApiDoc> apiDocList = sourceBuilder.getControllerApiData();
|
||||||
if (config.isAllInOne()) {
|
if (config.isAllInOne()) {
|
||||||
String version = DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT);
|
String version = config.isCoverOld() ? "" : "-V" + DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT);
|
||||||
builderTemplate.buildAllInOne(apiDocList, config, ALL_IN_ONE_MD_TPL, "AllInOne-V" + version + ".md");
|
builderTemplate.buildAllInOne(apiDocList, config, ALL_IN_ONE_MD_TPL, "AllInOne" + version + ".md");
|
||||||
} else {
|
} else {
|
||||||
builderTemplate.buildApiDoc(apiDocList, config, API_DOC_MD_TPL, API_EXTENSION);
|
builderTemplate.buildApiDoc(apiDocList, config, API_DOC_MD_TPL, API_EXTENSION);
|
||||||
builderTemplate.buildErrorCodeDoc(config.getErrorCodes(), config, ERROR_CODE_LIST_MD_TPL, ERROR_CODE_LIST_MD);
|
builderTemplate.buildErrorCodeDoc(config.getErrorCodes(), config, ERROR_CODE_LIST_MD_TPL, ERROR_CODE_LIST_MD);
|
||||||
|
@ -52,6 +53,7 @@ public class ApiDocBuilder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of ApiDoc
|
* Get list of ApiDoc
|
||||||
|
*
|
||||||
* @param config ApiConfig
|
* @param config ApiConfig
|
||||||
* @return List of ApiDoc
|
* @return List of ApiDoc
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -103,6 +103,7 @@ public class DocBuilderTemplate {
|
||||||
tpl.binding(TemplateVariable.VERSION_LIST.getVariable(), config.getRevisionLogs());
|
tpl.binding(TemplateVariable.VERSION_LIST.getVariable(), config.getRevisionLogs());
|
||||||
tpl.binding(TemplateVariable.VERSION.getVariable(),now);
|
tpl.binding(TemplateVariable.VERSION.getVariable(),now);
|
||||||
tpl.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime);
|
tpl.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime);
|
||||||
|
tpl.binding(TemplateVariable.PROJECT_NAME.getVariable(),config.getProjectName());
|
||||||
if (null != config.getLanguage()) {
|
if (null != config.getLanguage()) {
|
||||||
if (DocLanguage.CHINESE.code.equals(config.getLanguage().getCode())) {
|
if (DocLanguage.CHINESE.code.equals(config.getLanguage().getCode())) {
|
||||||
tpl.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_CN_TITLE);
|
tpl.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_CN_TITLE);
|
||||||
|
|
|
@ -15,6 +15,7 @@ public enum TemplateVariable {
|
||||||
TITLE("title"),
|
TITLE("title"),
|
||||||
ERROR_LIST_TITLE("errorListTitle"),
|
ERROR_LIST_TITLE("errorListTitle"),
|
||||||
CREATE_TIME("createTime"),
|
CREATE_TIME("createTime"),
|
||||||
|
PROJECT_NAME("projectName"),
|
||||||
VERSION("version");
|
VERSION("version");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,12 @@ public class ApiConfig {
|
||||||
*/
|
*/
|
||||||
private List<ApiReqHeader> requestHeaders;
|
private List<ApiReqHeader> requestHeaders;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.7.5
|
||||||
|
* cover old all in one markdown
|
||||||
|
*/
|
||||||
|
private boolean coverOld;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list of custom response filed
|
* list of custom response filed
|
||||||
*/
|
*/
|
||||||
|
@ -84,11 +90,18 @@ public class ApiConfig {
|
||||||
*/
|
*/
|
||||||
private boolean adoc;
|
private boolean adoc;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* api data dictionary
|
* api data dictionary
|
||||||
*/
|
*/
|
||||||
private List<ApiDataDictConfig> dataDictConfigs;
|
private List<ApiDataDictConfig> dataDictConfigs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.7.5
|
||||||
|
* project name
|
||||||
|
*/
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
|
||||||
public String getServerUrl() {
|
public String getServerUrl() {
|
||||||
return serverUrl;
|
return serverUrl;
|
||||||
|
@ -204,5 +217,19 @@ public class ApiConfig {
|
||||||
this.dataDictConfigs = CollectionUtil.asList(dataDictConfigs);
|
this.dataDictConfigs = CollectionUtil.asList(dataDictConfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCoverOld() {
|
||||||
|
return coverOld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoverOld(boolean coverOld) {
|
||||||
|
this.coverOld = coverOld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProjectName() {
|
||||||
|
return projectName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectName(String projectName) {
|
||||||
|
this.projectName = projectName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
<%if(isNotEmpty(projectName)){%>
|
||||||
|
# ${projectName}
|
||||||
|
<%}%>
|
||||||
<%if(isNotEmpty(revisionLogList)){%>
|
<%if(isNotEmpty(revisionLogList)){%>
|
||||||
Version | Update Time | Status | Author | Description
|
Version | Update Time | Status | Author | Description
|
||||||
------|--------|-----|------|-------
|
------|--------|-----|------|-------
|
||||||
|
@ -13,11 +16,11 @@ ${revisionLog.version}|${revisionLog.revisionTime}|${revisionLog.status}|${revis
|
||||||
<%
|
<%
|
||||||
for(api in apiDocList){
|
for(api in apiDocList){
|
||||||
%>
|
%>
|
||||||
# ${api.order}. ${api.desc}
|
## ${api.desc}
|
||||||
<%
|
<%
|
||||||
for(doc in api.list){
|
for(doc in api.list){
|
||||||
%>
|
%>
|
||||||
## ${api.order}.${doc.order} ${doc.desc}
|
### ${doc.desc}
|
||||||
**URL:** ${doc.url}
|
**URL:** ${doc.url}
|
||||||
|
|
||||||
**Type:** ${doc.type}
|
**Type:** ${doc.type}
|
||||||
|
@ -74,7 +77,7 @@ ${doc.responseUsage}
|
||||||
<% } %>
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<%if(isNotEmpty(errorCodeList)){%>
|
<%if(isNotEmpty(errorCodeList)){%>
|
||||||
# ${apiDocList.~size+1}. ${errorListTitle}
|
## ${errorListTitle}
|
||||||
Error code |Description
|
Error code |Description
|
||||||
---|---
|
---|---
|
||||||
<%
|
<%
|
||||||
|
|
Loading…
Reference in New Issue