delete Source Builder and update method for plugin
This commit is contained in:
parent
2862fe41f0
commit
e71a493e3f
|
@ -26,11 +26,20 @@ public class AdocDocBuilder {
|
|||
*
|
||||
* @param config ApiConfig
|
||||
*/
|
||||
public static void builderControllersApi(ApiConfig config) {
|
||||
public static void builderApiDoc(ApiConfig config) {
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
buildApiDoc(config,javaProjectBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for plugin
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config,JavaProjectBuilder javaProjectBuilder) {
|
||||
config.setAdoc(true);
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config,javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
|
@ -48,10 +57,11 @@ public class AdocDocBuilder {
|
|||
* @param config ApiConfig
|
||||
* @param controllerName controller name
|
||||
*/
|
||||
public static void buildSingleControllerApi(ApiConfig config, String controllerName) {
|
||||
config.setAdoc(true);
|
||||
public static void buildSingleApiDoc(ApiConfig config, String controllerName) {
|
||||
config.setAdoc(false);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, new JavaProjectBuilder());
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
builderTemplate.buildSingleControllerApi(config.getOutPath(), controllerName, API_DOC_ADOC_TPL, API_EXTENSION);
|
||||
builderTemplate.buildSingleApi(configBuilder, controllerName, API_DOC_ADOC_TPL, API_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.power.doc.builder;
|
|||
import com.power.doc.model.ApiAllData;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiDoc;
|
||||
import com.power.doc.template.IDocBuildTemplate;
|
||||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
|
||||
/**
|
||||
|
@ -24,20 +26,4 @@ public class ApiDataBuilder {
|
|||
builderTemplate.getApiData(config,javaProjectBuilder);
|
||||
return builderTemplate.getApiData(config,javaProjectBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get single api data
|
||||
*
|
||||
* @param config ApiConfig
|
||||
* @param controllerName controller name
|
||||
* @return ApiDoc
|
||||
*/
|
||||
public static ApiDoc getApiData(ApiConfig config, String controllerName) {
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInitForGetApiData(config);
|
||||
config.setMd5EncryptedHtmlName(true);
|
||||
JavaProjectBuilder projectBuilder = new JavaProjectBuilder();
|
||||
SourceBuilder sourceBuilder = new SourceBuilder(config,projectBuilder);
|
||||
return sourceBuilder.getSingleControllerApiData(controllerName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,17 +25,26 @@ public class ApiDocBuilder {
|
|||
/**
|
||||
* @param config ApiConfig
|
||||
*/
|
||||
public static void builderControllersApi(ApiConfig config) {
|
||||
config.setAdoc(false);
|
||||
public static void buildApiDoc(ApiConfig config) {
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
buildApiDoc(config, javaProjectBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for plugin
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
||||
config.setAdoc(false);
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config,javaProjectBuilder);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
String version = config.isCoverOld() ? "" : "-V" + DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT);
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder,ALL_IN_ONE_MD_TPL, "AllInOne" + version + ".md");
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_MD_TPL, "AllInOne" + version + ".md");
|
||||
} else {
|
||||
builderTemplate.buildApiDoc(apiDocList, config, API_DOC_MD_TPL, API_EXTENSION);
|
||||
builderTemplate.buildErrorCodeDoc(config, ERROR_CODE_LIST_MD_TPL, ERROR_CODE_LIST_MD);
|
||||
|
@ -48,10 +57,12 @@ public class ApiDocBuilder {
|
|||
* @param config (ApiConfig
|
||||
* @param controllerName controller name
|
||||
*/
|
||||
public static void buildSingleControllerApi(ApiConfig config, String controllerName) {
|
||||
public static void buildSingleApiDoc(ApiConfig config, String controllerName) {
|
||||
config.setAdoc(false);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
builderTemplate.buildSingleControllerApi(config.getOutPath(), controllerName, API_DOC_MD_TPL, API_EXTENSION);
|
||||
builderTemplate.buildSingleApi(configBuilder, controllerName, API_DOC_MD_TPL, API_EXTENSION);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,15 +167,16 @@ public class DocBuilderTemplate {
|
|||
* @param template template
|
||||
* @param fileExtension file extension
|
||||
*/
|
||||
public void buildSingleControllerApi(String outPath, String controllerName, String template, String fileExtension) {
|
||||
FileUtil.mkdirs(outPath);
|
||||
SourceBuilder sourceBuilder = new SourceBuilder(Boolean.TRUE, new JavaProjectBuilder());
|
||||
ApiDoc doc = sourceBuilder.getSingleControllerApiData(controllerName);
|
||||
public void buildSingleApi(ProjectDocConfigBuilder projectBuilder, String controllerName, String template, String fileExtension) {
|
||||
ApiConfig config = projectBuilder.getApiConfig();
|
||||
FileUtil.mkdirs(config.getOutPath());
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
ApiDoc doc = docBuildTemplate.getSingleApiData(projectBuilder,controllerName);
|
||||
Template mapper = BeetlTemplateUtil.getByName(template);
|
||||
mapper.binding(TemplateVariable.DESC.getVariable(), doc.getDesc());
|
||||
mapper.binding(TemplateVariable.NAME.getVariable(), doc.getName());
|
||||
mapper.binding(TemplateVariable.LIST.getVariable(), doc.getList());
|
||||
FileUtil.writeFileNotAppend(mapper.render(), outPath + FILE_SEPARATOR + doc.getName() + fileExtension);
|
||||
FileUtil.writeFileNotAppend(mapper.render(), config.getOutPath() + FILE_SEPARATOR + doc.getName() + fileExtension);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,10 +37,19 @@ public class HtmlApiDocBuilder {
|
|||
*
|
||||
* @param config config
|
||||
*/
|
||||
public static void builderControllersApi(ApiConfig config) {
|
||||
public static void buildApiDoc(ApiConfig config) {
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
buildApiDoc(config,javaProjectBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for plugin
|
||||
* @param config ApiConfig
|
||||
* @param javaProjectBuilder ProjectDocConfigBuilder
|
||||
*/
|
||||
public static void buildApiDoc(ApiConfig config,JavaProjectBuilder javaProjectBuilder) {
|
||||
DocBuilderTemplate builderTemplate = new DocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder();
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config,javaProjectBuilder);
|
||||
IDocBuildTemplate docBuildTemplate = new SpringBootDocBuildTemplate();
|
||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
|
@ -52,11 +61,10 @@ public class HtmlApiDocBuilder {
|
|||
List<ApiDocDict> apiDocDictList = builderTemplate.buildDictionary(config,javaProjectBuilder);
|
||||
buildIndex(apiDocList, config);
|
||||
copyCss(config.getOutPath());
|
||||
buildApiDoc(apiDocList, config.getOutPath());
|
||||
buildDoc(apiDocList, config.getOutPath());
|
||||
buildErrorCodeDoc(config.getErrorCodes(), config.getOutPath());
|
||||
buildDictionary(apiDocDictList, config.getOutPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void copyCss(String outPath) {
|
||||
|
@ -111,7 +119,7 @@ public class HtmlApiDocBuilder {
|
|||
* @param apiDocList list of api doc
|
||||
* @param outPath output path
|
||||
*/
|
||||
private static void buildApiDoc(List<ApiDoc> apiDocList, String outPath) {
|
||||
private static void buildDoc(List<ApiDoc> apiDocList, String outPath) {
|
||||
FileUtil.mkdirs(outPath);
|
||||
Template htmlApiDoc;
|
||||
String strTime = DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -105,8 +105,6 @@ public class DocGlobalConstants {
|
|||
|
||||
public static final String POSTMAN_MODE_RAW ="raw";
|
||||
|
||||
public static final String HTTP_POST = "POST";
|
||||
|
||||
public static final String SHORT_MULTIPART_FILE_FULLY = "MultipartFile";
|
||||
|
||||
public static final String DEFAULT_SERVER_URL = "http://{server}";
|
||||
|
@ -118,8 +116,4 @@ public class DocGlobalConstants {
|
|||
public static final String CURL_POST_JSON = "curl -X POST -H 'Content-Type: application/json; charset=utf-8' -i ";
|
||||
|
||||
public static final String ENMPTY = "";
|
||||
|
||||
public static final String STATIC = "static";
|
||||
|
||||
public static final String FINAL = "final";
|
||||
}
|
||||
|
|
|
@ -114,6 +114,8 @@ public interface IDocBuildTemplate {
|
|||
|
||||
List<ApiDoc> getApiData(ProjectDocConfigBuilder projectBuilder);
|
||||
|
||||
ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder,String apiClassName);
|
||||
|
||||
|
||||
boolean ignoreReturnObject(String typeName);
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate {
|
|||
return apiDocList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder,String apiClassName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreReturnObject(String typeName) {
|
||||
if (JavaClassValidateUtil.isMvcIgnoreParams(typeName)) {
|
||||
|
|
|
@ -14,7 +14,6 @@ public class JavaFieldUtil {
|
|||
* @return boolean
|
||||
*/
|
||||
public static boolean checkGenerics(List<JavaField> fields) {
|
||||
checkGenerics:
|
||||
for (JavaField field : fields) {
|
||||
if (field.getType().getFullyQualifiedName().length() == 1) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue