From 3dee302e76bcd6135035efcb17b22ddc62fdd665 Mon Sep 17 00:00:00 2001 From: chenqi <1535985458@qq.com> Date: Sat, 17 Jul 2021 20:39:38 +0800 Subject: [PATCH 1/3] feat: add requestParams for git #132 --- .../template/SpringBootDocBuildTemplate.java | 55 +++++++++---------- .../java/com/power/doc/utils/DocUtil.java | 23 +++++++- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java index 450e6ca..bd464b0 100644 --- a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java @@ -225,7 +225,6 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { apiMethodDoc.setQueryParams(apiMethodReqParam.getQueryParams()); apiMethodDoc.setRequestParams(apiMethodReqParam.getRequestParams()); } - List allApiReqParams; if (this.configApiReqParams != null) { @@ -235,38 +234,26 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { final List headerParamList = reqParamMap.getOrDefault(ApiReqParamInTypeEnum.HEADER.getValue(), Collections.emptyList()); allApiReqParams = Stream.of(apiReqParams, headerParamList).filter(Objects::nonNull) .flatMap(Collection::stream).distinct().collect(Collectors.toList()); - - // query param handle -// final List queryParamList = reqParamMap.getOrDefault(ApiReqParamInTypeEnum.QUERY.getValue(), Collections.emptyList()); -// AtomicInteger querySize = apiMethodDoc.getQueryParams() == null ? new AtomicInteger(1) -// : new AtomicInteger(apiMethodDoc.getQueryParams().size() + 1); -// final List defaultQueryList = queryParamList.stream() -// .map(param -> ApiReqParam.convertToApiParam(param).setQueryParam(true).setId(querySize.getAndIncrement())) -// .collect(Collectors.toList()); -// -// apiMethodDoc.setQueryParams(Stream.of(apiMethodDoc.getQueryParams(), defaultQueryList).filter(Objects::nonNull) -// .flatMap(Collection::stream).distinct().collect(Collectors.toList())); -// -// // path param handle -// final List pathParamList = reqParamMap.getOrDefault(ApiReqParamInTypeEnum.PATH.getValue(), Collections.emptyList()); -// AtomicInteger pathSize = apiMethodDoc.getPathParams() == null ? new AtomicInteger(1) -// : new AtomicInteger(apiMethodDoc.getPathParams().size() + 1); -// final List defaultPathList = pathParamList.stream() -// .map(param -> ApiReqParam.convertToApiParam(param).setPathParam(true).setId(pathSize.getAndIncrement())) -// .collect(Collectors.toList()); -// -// apiMethodDoc.setPathParams(Stream.of(apiMethodDoc.getPathParams(), defaultPathList).filter(Objects::nonNull) -// .flatMap(Collection::stream).distinct().collect(Collectors.toList())); - } else { allApiReqParams = apiReqParams.stream().filter(param -> filterPath(requestMapping, param)).collect(Collectors.toList()); } -// allApiReqParams.removeIf(apiReqHeader -> filterPath(requestMapping, apiReqHeader)); //reduce create in template apiMethodDoc.setHeaders(this.createDocRenderHeaders(allApiReqParams, apiConfig.isAdoc())); apiMethodDoc.setRequestHeaders(allApiReqParams); + String path = apiMethodDoc.getPath().split(";")[0]; + String pathUrl = DocUtil.formatPathUrl(path); + List pathParams = apiMethodDoc.getPathParams(); + Iterator pathIterator = pathParams.iterator(); + while (pathIterator.hasNext()) { + ApiParam next = pathIterator.next(); + String pathKey = "{" + next.getField() + "}"; + if (!pathUrl.contains(pathKey)) { + pathIterator.remove(); + } + } + // build request json ApiRequestExample requestExample = buildReqJson(docJavaMethod, apiMethodDoc, requestMapping.getMethodType(), projectBuilder); @@ -315,12 +302,10 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { Map pathParamsMap = new LinkedHashMap<>(); Map queryParamsMap = new LinkedHashMap<>(); - Stream.of(apiMethodDoc.getPathParams()).filter(Objects::nonNull) - .flatMap(pl -> pl.stream().filter(ApiParam::isConfigParam)) + apiMethodDoc.getPathParams().stream().filter(Objects::nonNull).filter(ApiParam::isConfigParam) .forEach(param -> pathParamsMap.put(param.getField(), param.getValue())); - Stream.of(apiMethodDoc.getQueryParams()).filter(Objects::nonNull) - .flatMap(pl -> pl.stream().filter(ApiParam::isConfigParam)) + apiMethodDoc.getQueryParams().stream().filter(Objects::nonNull).filter(ApiParam::isConfigParam) .forEach(param -> queryParamsMap.put(param.getField(), param.getValue())); List methodAnnotations = method.getAnnotations(); @@ -407,6 +392,9 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { String[] globGicName = DocClassUtil.getSimpleGicName(gicTypeName); String comment = this.paramCommentResolve(paramsComments.get(paramName)); String mockValue = createMockValue(paramsComments, paramName, typeName, simpleTypeName); + if (queryParamsMap.containsKey(paramName)) { + mockValue = queryParamsMap.get(paramName); + } if (requestFieldToUnderline) { paramName = StringUtil.camelToUnderline(paramName); } @@ -466,6 +454,9 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { Object value = JavaClassUtil.getEnumValue(javaClass, Boolean.TRUE); mockValue = StringUtil.removeQuotes(String.valueOf(value)); } + if (pathParamsMap.containsKey(paramName)) { + mockValue = pathParamsMap.get(paramName); + } pathParamsMap.put(paramName, mockValue); paramAdded = true; } @@ -896,9 +887,15 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { for (ApiParam param : paramList) { param.setValue(StringUtil.removeDoubleQuotes(param.getValue())); if (param.isPathParam()) { + if (pathReqParamMap.containsKey(param.getField())) { + param.setConfigParam(true).setValue(pathReqParamMap.get(param.getField()).getValue()); + } param.setId(pathParams.size() + 1); pathParams.add(param); } else if (param.isQueryParam() || requestBodyCounter < 1) { + if (queryReqParamMap.containsKey(param.getField())) { + param.setConfigParam(true).setValue(queryReqParamMap.get(param.getField()).getValue()); + } param.setId(queryParams.size() + 1); queryParams.add(param); } else { diff --git a/src/main/java/com/power/doc/utils/DocUtil.java b/src/main/java/com/power/doc/utils/DocUtil.java index d6c47de..6fd8799 100644 --- a/src/main/java/com/power/doc/utils/DocUtil.java +++ b/src/main/java/com/power/doc/utils/DocUtil.java @@ -45,7 +45,7 @@ import java.util.stream.Collectors; */ public class DocUtil { - private static Faker faker = new Faker(new Locale(System.getProperty(DocGlobalConstants.DOC_LANGUAGE))); + private static Faker faker = new Faker(new Locale("en-US")); //private static Faker faker = new Faker(new Locale("smart-doc_language")); private static Faker enFaker = new Faker(new Locale("en-US")); @@ -288,6 +288,27 @@ public class DocUtil { return builder.toString(); } + /** + * // /detail/{id:[a-zA-Z0-9]{3}}/{name:[a-zA-Z0-9]{3}} + * 去除正则表达式 + * @param str + * @return + */ + public static String formatPathUrl(String str) { + if (!str.contains(":")) { + return str; + } + String[] strArr = str.split("/"); + for (int i = 0; i < strArr.length; i++) { + String pathParam = strArr[i]; + if (pathParam.contains(":")) { + strArr[i] = pathParam.substring(0, pathParam.indexOf(":")) + "}"; + } + } + str = StringUtils.join(Arrays.asList(strArr), '/'); + return str; + } + /** * handle spring mvc method * From 44397612c40cd9c448e1eb52881207984da8e5b2 Mon Sep 17 00:00:00 2001 From: chenqi <1535985458@qq.com> Date: Sat, 31 Jul 2021 15:40:43 +0800 Subject: [PATCH 2/3] feat: add custom tag of @tag to implements tag --- .../java/com/power/doc/constants/DocTags.java | 5 ++ src/main/java/com/power/doc/model/ApiDoc.java | 36 ++++++++- .../com/power/doc/model/ApiMethodDoc.java | 25 ++++++- .../power/doc/template/IDocBuildTemplate.java | 5 ++ .../template/SpringBootDocBuildTemplate.java | 75 +++++++++++++++++++ 5 files changed, 142 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/power/doc/constants/DocTags.java b/src/main/java/com/power/doc/constants/DocTags.java index 161a9b9..e11d916 100644 --- a/src/main/java/com/power/doc/constants/DocTags.java +++ b/src/main/java/com/power/doc/constants/DocTags.java @@ -119,4 +119,9 @@ public interface DocTags { * response tag @since 2.2.0 */ String API_RESPONSE = "response"; + + /** + * custom @tag + */ + String TAG = "tag"; } diff --git a/src/main/java/com/power/doc/model/ApiDoc.java b/src/main/java/com/power/doc/model/ApiDoc.java index e374f4c..829bc85 100644 --- a/src/main/java/com/power/doc/model/ApiDoc.java +++ b/src/main/java/com/power/doc/model/ApiDoc.java @@ -25,6 +25,7 @@ package com.power.doc.model; import com.power.common.util.StringUtil; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -35,7 +36,7 @@ public class ApiDoc implements Comparable { * * @since 1.7+ */ - public int order; + public Integer order; /** * controller name @@ -49,6 +50,13 @@ public class ApiDoc implements Comparable { */ private String alias; + /** + * tags + * + * @author cqmike + */ + private String[] tags; + /** * List of method doc */ @@ -98,11 +106,11 @@ public class ApiDoc implements Comparable { this.desc = desc; } - public int getOrder() { + public Integer getOrder() { return order; } - public void setOrder(int order) { + public void setOrder(Integer order) { this.order = order; } @@ -114,6 +122,14 @@ public class ApiDoc implements Comparable { this.alias = alias; } + public String[] getTags() { + return tags; + } + + public void setTags(String[] tags) { + this.tags = tags; + } + public String getLink() { if (StringUtil.isNotEmpty(link)) { return link; @@ -133,6 +149,20 @@ public class ApiDoc implements Comparable { return name.compareTo(o.getName()); } + public static ApiDoc buildTagApiDoc(ApiDoc source, String tag, ApiMethodDoc methodDoc) { + ApiDoc apiDoc = new ApiDoc(); + apiDoc.setAlias(source.getAlias()); + apiDoc.setLink(source.getLink()); + apiDoc.setDesc(tag); + apiDoc.setAuthor(source.getAuthor()); + apiDoc.setName(tag); + apiDoc.setList(new ArrayList<>()); + ApiMethodDoc clone = methodDoc.clone(); + clone.setOrder(apiDoc.getList().size() + 1); + apiDoc.getList().add(clone); + return apiDoc; + } + @Override public String toString() { diff --git a/src/main/java/com/power/doc/model/ApiMethodDoc.java b/src/main/java/com/power/doc/model/ApiMethodDoc.java index 93fd934..333e644 100644 --- a/src/main/java/com/power/doc/model/ApiMethodDoc.java +++ b/src/main/java/com/power/doc/model/ApiMethodDoc.java @@ -33,7 +33,7 @@ import java.util.Map; /** * java api method info model. */ -public class ApiMethodDoc implements Serializable { +public class ApiMethodDoc implements Serializable, Cloneable { private static final long serialVersionUID = 7211922919532562867L; @@ -202,6 +202,11 @@ public class ApiMethodDoc implements Serializable { */ private boolean listParam = false; + /** + * tags + */ + private String[] tags; + public Integer getIsRequestArray() { return isRequestArray; } @@ -462,6 +467,15 @@ public class ApiMethodDoc implements Serializable { this.page = page; } + public String[] getTags() { + return tags; + } + + public ApiMethodDoc setTags(String[] tags) { + this.tags = tags; + return this; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); @@ -510,4 +524,13 @@ public class ApiMethodDoc implements Serializable { sb.append('}'); return sb.toString(); } + + @Override + public ApiMethodDoc clone() { + try { + return (ApiMethodDoc) super.clone(); + } catch (CloneNotSupportedException e) { + throw new RuntimeException("clone apiMethodDoc is error", e); + } + } } diff --git a/src/main/java/com/power/doc/template/IDocBuildTemplate.java b/src/main/java/com/power/doc/template/IDocBuildTemplate.java index 1295ad8..799698a 100644 --- a/src/main/java/com/power/doc/template/IDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/IDocBuildTemplate.java @@ -83,6 +83,11 @@ public interface IDocBuildTemplate { apiDoc.setAuthor(classAuthor); apiDoc.setAlias(controllerName); //apiDoc.setAuthor(); + + // handle class tags + List classTags = cls.getTagsByName(DocTags.TAG); + apiDoc.setTags(classTags.stream().map(DocletTag::getValue).toArray(String[]::new)); + if (isUseMD5) { String name = DocUtil.generateId(apiDoc.getName()); apiDoc.setAlias(name); diff --git a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java index 982fcb7..f820f49 100644 --- a/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/SpringBootDocBuildTemplate.java @@ -37,6 +37,7 @@ import com.power.doc.model.request.RequestMapping; import com.power.doc.utils.*; import com.thoughtworks.qdox.model.*; import com.thoughtworks.qdox.model.expression.AnnotationValue; +import org.apache.commons.lang3.ArrayUtils; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -88,6 +89,9 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { List apiMethodDocs = buildControllerMethod(cls, apiConfig, projectBuilder); this.handleApiDoc(cls, apiDocList, apiMethodDocs, order, apiConfig.isMd5EncryptedHtmlName()); } + // handle TagsApiDoc + apiDocList = handleTagsApiDoc(apiDocList); + // sort if (apiConfig.isSortByTitle()) { Collections.sort(apiDocList); @@ -100,6 +104,72 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { return apiDocList; } + /** + * handle tags to api doc + * copy the same tag + * + * @author cqmike + * @param apiDocList + */ + private List handleTagsApiDoc(List apiDocList) { + if (CollectionUtil.isEmpty(apiDocList)) { + return Collections.emptyList(); + } + + // all class tag copy + Map copyMap = new HashMap<>(); + apiDocList.forEach(doc -> { + String[] tags = doc.getTags(); + if (ArrayUtils.isEmpty(tags)) { + tags = new String[]{doc.getName()}; + } + + for (String tag : tags) { + tag = StringUtil.trim(tag); + copyMap.computeIfPresent(tag, (k, v) -> { + List list = CollectionUtil.isEmpty(v.getList()) ? new ArrayList<>() : v.getList(); + list.addAll(doc.getList()); + v.setList(list); + return v; + }); + copyMap.putIfAbsent(tag, doc); + } + }); + + // handle method tag + Map allMap = new HashMap<>(copyMap); + allMap.forEach((k, v) -> { + List methodDocList = v.getList(); + methodDocList.forEach(method -> { + String[] tags = method.getTags(); + if (ArrayUtils.isEmpty(tags)) { + return; + } + for (String tag : tags) { + tag = StringUtil.trim(tag); + copyMap.computeIfPresent(tag, (k1, v2) -> { + method.setOrder(v2.getList().size() + 1); + v2.getList().add(method); + return v2; + }); + copyMap.putIfAbsent(tag, ApiDoc.buildTagApiDoc(v, tag, method)); + } + }); + }); + + List apiDocs = new ArrayList<>(copyMap.values()); + int index = apiDocs.size() - 1; + for (ApiDoc apiDoc : apiDocs) { + if (apiDoc.getOrder() == null) { + apiDoc.setOrder(index++); + } + } + apiDocs.sort(Comparator.comparing(ApiDoc::getOrder)); + return apiDocs; + } + + + @Override public ApiDoc getSingleApiData(ProjectDocConfigBuilder projectBuilder, String apiClassName) { return null; @@ -179,6 +249,11 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate { } else { apiMethodDoc.setGroup(group); } + + // handle tags + List tags = method.getTagsByName(DocTags.TAG); + apiMethodDoc.setTags(tags.stream().map(DocletTag::getValue).toArray(String[]::new)); + methodOrder++; apiMethodDoc.setName(method.getName()); apiMethodDoc.setOrder(methodOrder); From 388c178662269c58c9fa694eb702ef1bdc39f02c Mon Sep 17 00:00:00 2001 From: chenqi <1535985458@qq.com> Date: Sun, 1 Aug 2021 23:19:39 +0800 Subject: [PATCH 3/3] feat: add group --- .../com/power/doc/builder/AdocDocBuilder.java | 2 + .../com/power/doc/builder/ApiDocBuilder.java | 2 + .../power/doc/builder/DocBuilderTemplate.java | 2 + .../power/doc/builder/HtmlApiDocBuilder.java | 4 +- .../com/power/doc/builder/TornaBuilder.java | 30 +- .../java/com/power/doc/model/ApiConfig.java | 18 + src/main/java/com/power/doc/model/ApiDoc.java | 66 +++ .../java/com/power/doc/model/ApiGroup.java | 55 ++ .../power/doc/template/IDocBuildTemplate.java | 52 ++ src/main/resources/template/AllInOne.adoc | 19 +- src/main/resources/template/AllInOne.btl | 7 +- src/main/resources/template/debug-all.html | 516 +++++++++++++++++- .../resources/template/js/search_all.js.btl | 106 ++-- src/test/java/com/power/doc/ApiDocTest.java | 2 +- 14 files changed, 799 insertions(+), 82 deletions(-) create mode 100644 src/main/java/com/power/doc/model/ApiGroup.java diff --git a/src/main/java/com/power/doc/builder/AdocDocBuilder.java b/src/main/java/com/power/doc/builder/AdocDocBuilder.java index d7a8fc5..f703f5e 100644 --- a/src/main/java/com/power/doc/builder/AdocDocBuilder.java +++ b/src/main/java/com/power/doc/builder/AdocDocBuilder.java @@ -31,6 +31,7 @@ import com.power.doc.template.SpringBootDocBuildTemplate; import com.thoughtworks.qdox.JavaProjectBuilder; import java.util.List; +import java.util.stream.Collectors; import static com.power.doc.constants.DocGlobalConstants.*; @@ -71,6 +72,7 @@ public class AdocDocBuilder { List apiDocList = docBuildTemplate.getApiData(configBuilder); if (config.isAllInOne()) { String docName = builderTemplate.allInOneDocName(config,INDEX_DOC,".doc"); + apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config); builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_ADOC_TPL, docName); } else { builderTemplate.buildApiDoc(apiDocList, config, API_DOC_ADOC_TPL, API_EXTENSION); diff --git a/src/main/java/com/power/doc/builder/ApiDocBuilder.java b/src/main/java/com/power/doc/builder/ApiDocBuilder.java index c9b119f..1c97568 100644 --- a/src/main/java/com/power/doc/builder/ApiDocBuilder.java +++ b/src/main/java/com/power/doc/builder/ApiDocBuilder.java @@ -31,6 +31,7 @@ import com.power.doc.template.SpringBootDocBuildTemplate; import com.thoughtworks.qdox.JavaProjectBuilder; import java.util.List; +import java.util.stream.Collectors; import static com.power.doc.constants.DocGlobalConstants.*; @@ -70,6 +71,7 @@ public class ApiDocBuilder { if (config.isAllInOne()) { String version = config.isCoverOld() ? "" : "-V" + DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT); String docName = builderTemplate.allInOneDocName(config,"AllInOne" + version + ".md",".md"); + apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config); builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_MD_TPL, docName); } else { builderTemplate.buildApiDoc(apiDocList, config, API_DOC_MD_TPL, API_EXTENSION); diff --git a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java index 40978c0..e460282 100644 --- a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java +++ b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java @@ -169,6 +169,7 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate { apiDoc1.setList(new ArrayList<>(0)); apiDoc1.setLink("error_code_list"); apiDoc1.setAlias("error"); + apiDoc1.setGroup(apiDoc1.getDesc()); apiDocs.add(apiDoc1); } // set dict list @@ -178,6 +179,7 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate { apiDoc1.setLink("dict_list"); apiDoc1.setAlias("dict"); apiDoc1.setDesc(titleMap.get(TemplateVariable.DICT_LIST_TITLE.getVariable())); + apiDoc1.setGroup(apiDoc1.getDesc()); List methodDocs = new ArrayList<>(); for (ApiDocDict apiDocDict : apiDocDictList) { ApiMethodDoc methodDoc = new ApiMethodDoc(); diff --git a/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java b/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java index 693fa95..87ed083 100644 --- a/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java +++ b/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java @@ -27,13 +27,14 @@ import com.power.doc.factory.BuildTemplateFactory; 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.power.doc.utils.BeetlTemplateUtil; import com.thoughtworks.qdox.JavaProjectBuilder; import org.apache.commons.lang3.StringUtils; import org.beetl.core.Template; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import static com.power.doc.constants.DocGlobalConstants.*; @@ -74,6 +75,7 @@ public class HtmlApiDocBuilder { Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS); FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS); if (config.isAllInOne()) { + apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config); if (config.isCreateDebugPage()) { INDEX_HTML = DEBUG_PAGE_ALL_TPL; if (StringUtils.isNotEmpty(config.getAllInOneDocFileName())) { diff --git a/src/main/java/com/power/doc/builder/TornaBuilder.java b/src/main/java/com/power/doc/builder/TornaBuilder.java index a51699c..9f01320 100644 --- a/src/main/java/com/power/doc/builder/TornaBuilder.java +++ b/src/main/java/com/power/doc/builder/TornaBuilder.java @@ -80,6 +80,7 @@ public class TornaBuilder { ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder); IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework()); List apiDocList = docBuildTemplate.getApiData(configBuilder); + apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config); buildTorna(apiDocList, config, javaProjectBuilder); } @@ -94,19 +95,32 @@ public class TornaBuilder { TornaApi tornaApi = new TornaApi(); tornaApi.setAuthor(StringUtil.isEmpty(apiConfig.getAuthor()) ? System.getProperty("user.name") : apiConfig.getAuthor()); Apis api; - List apisList = new ArrayList<>(); + List groupApiList = new ArrayList<>(); //添加接口数据 - for (ApiDoc a : apiDocs) { + for (ApiDoc groupApi : apiDocs) { + + List apisList = new ArrayList<>(); + List childrenApiDocs = groupApi.getChildrenApiDocs(); + for (ApiDoc a : childrenApiDocs) { + api = new Apis(); + api.setName(StringUtils.isBlank(a.getDesc()) ? a.getName() : a.getDesc()); + api.setItems(buildApis(a.getList(), TornaUtil.setDebugEnv(apiConfig, tornaApi))); + api.setIsFolder(TornaConstants.YES); + api.setAuthor(a.getAuthor()); + api.setOrderIndex(a.getOrder()); + apisList.add(api); + } api = new Apis(); - api.setName(StringUtils.isBlank(a.getDesc()) ? a.getName() : a.getDesc()); - api.setItems(buildApis(a.getList(), TornaUtil.setDebugEnv(apiConfig, tornaApi))); + api.setName(StringUtils.isBlank(groupApi.getDesc()) ? groupApi.getName() : groupApi.getDesc()); + api.setAuthor(tornaApi.getAuthor()); + api.setOrderIndex(groupApi.getOrder()); api.setIsFolder(TornaConstants.YES); - api.setAuthor(a.getAuthor()); - api.setOrderIndex(a.getOrder()); - apisList.add(api); + api.setItems(apisList); + groupApiList.add(api); + } tornaApi.setCommonErrorCodes(buildErrorCode(apiConfig)); - tornaApi.setApis(apisList); + tornaApi.setApis(groupApiList); //推送文档信息 Map requestJson = TornaConstants.buildParams(PUSH, new Gson().toJson(tornaApi), apiConfig); //推送字典信息 diff --git a/src/main/java/com/power/doc/model/ApiConfig.java b/src/main/java/com/power/doc/model/ApiConfig.java index 22e9925..74769a8 100644 --- a/src/main/java/com/power/doc/model/ApiConfig.java +++ b/src/main/java/com/power/doc/model/ApiConfig.java @@ -26,8 +26,10 @@ import com.power.common.util.CollectionUtil; import com.power.doc.constants.DocLanguage; import com.power.doc.model.rpc.RpcApiDependency; +import java.util.Arrays; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * Description: @@ -347,6 +349,8 @@ public class ApiConfig { */ private String framework; + private List groups; + public String getPathPrefix() { return pathPrefix; } @@ -440,6 +444,20 @@ public class ApiConfig { this.requestHeaders.forEach(header -> header.setDesc(header.getDesc() + "(Global)")); } + public List getGroups() { + return groups; + } + + public ApiConfig setGroups(List groups) { + this.groups = groups; + return this; + } + + public ApiConfig setGroups(ApiGroup... groups) { + this.groups = CollectionUtil.asList(groups); + return this; + } + public List getRequestParams() { return requestParams; } diff --git a/src/main/java/com/power/doc/model/ApiDoc.java b/src/main/java/com/power/doc/model/ApiDoc.java index 829bc85..e27f1d8 100644 --- a/src/main/java/com/power/doc/model/ApiDoc.java +++ b/src/main/java/com/power/doc/model/ApiDoc.java @@ -57,6 +57,19 @@ public class ApiDoc implements Comparable { */ private String[] tags; + /** + * group + * + * @author cqmike + */ + private String group; + + /** + * class in package name + * + */ + private String packageName; + /** * List of method doc */ @@ -74,6 +87,16 @@ public class ApiDoc implements Comparable { private String author; + /** + * if this is group, then is true + */ + private boolean isFolder; + + /** + * children + */ + private List childrenApiDocs = new ArrayList<>(); + public String getAuthor() { return author; } @@ -141,6 +164,38 @@ public class ApiDoc implements Comparable { this.link = link; } + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + + public boolean isFolder() { + return isFolder; + } + + public void setFolder(boolean folder) { + isFolder = folder; + } + + public List getChildrenApiDocs() { + return childrenApiDocs; + } + + public void setChildrenApiDocs(List childrenApiDocs) { + this.childrenApiDocs = childrenApiDocs; + } + @Override public int compareTo(ApiDoc o) { if (Objects.nonNull(o.getDesc())) { @@ -155,6 +210,7 @@ public class ApiDoc implements Comparable { apiDoc.setLink(source.getLink()); apiDoc.setDesc(tag); apiDoc.setAuthor(source.getAuthor()); + apiDoc.setPackageName(source.getPackageName()); apiDoc.setName(tag); apiDoc.setList(new ArrayList<>()); ApiMethodDoc clone = methodDoc.clone(); @@ -164,6 +220,16 @@ public class ApiDoc implements Comparable { } + public static ApiDoc buildGroupApiDoc(String group) { + ApiDoc apiDoc = new ApiDoc(); + apiDoc.setFolder(true); + apiDoc.setGroup(group); + apiDoc.setName(group); + apiDoc.setDesc(group); + apiDoc.setChildrenApiDocs(new ArrayList<>()); + return apiDoc; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); diff --git a/src/main/java/com/power/doc/model/ApiGroup.java b/src/main/java/com/power/doc/model/ApiGroup.java new file mode 100644 index 0000000..eb813b5 --- /dev/null +++ b/src/main/java/com/power/doc/model/ApiGroup.java @@ -0,0 +1,55 @@ +package com.power.doc.model; + +/** + * api group + * + * @author cqmike + * @version 1.0.0 + * @since 2021年07月31日 16:39:00 + */ +public class ApiGroup { + + /** + * group name + */ + private String name; + + /** + * package name + * support patten + */ + private String apis; + + /** + * url path + * support patten + */ + private String paths; + + public String getName() { + return name; + } + + public ApiGroup setName(String name) { + this.name = name; + return this; + } + + public String getApis() { + return apis; + } + + public ApiGroup setApis(String apis) { + this.apis = apis; + return this; + } + + public String getPaths() { + return paths; + } + + public ApiGroup setPaths(String paths) { + this.paths = paths; + return this; + } +} diff --git a/src/main/java/com/power/doc/template/IDocBuildTemplate.java b/src/main/java/com/power/doc/template/IDocBuildTemplate.java index 799698a..70468b8 100644 --- a/src/main/java/com/power/doc/template/IDocBuildTemplate.java +++ b/src/main/java/com/power/doc/template/IDocBuildTemplate.java @@ -35,6 +35,8 @@ import com.thoughtworks.qdox.model.JavaMethod; import com.thoughtworks.qdox.model.JavaType; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; import static com.power.doc.constants.DocGlobalConstants.NO_COMMENTS_FOUND; import static com.power.doc.constants.DocTags.IGNORE_RESPONSE_BODY_ADVICE; @@ -82,6 +84,8 @@ public interface IDocBuildTemplate { apiDoc.setName(controllerName); apiDoc.setAuthor(classAuthor); apiDoc.setAlias(controllerName); + apiDoc.setFolder(true); + apiDoc.setPackageName(cls.getPackage().getName()); //apiDoc.setAuthor(); // handle class tags @@ -99,6 +103,54 @@ public interface IDocBuildTemplate { } + /** + * handle group api docs + * + * @author cqmike + * @param apiDocList + * @param apiConfig + */ + default List handleApiGroup(List apiDocList, ApiConfig apiConfig) { + if (CollectionUtil.isEmpty(apiDocList) || apiConfig == null) { + return apiDocList; + } + + List groups = apiConfig.getGroups(); + ApiDoc defaultGroup = ApiDoc.buildGroupApiDoc("default"); + + List finalApiDocs = new ArrayList<>(); + finalApiDocs.add(defaultGroup); + AtomicInteger order = new AtomicInteger(1); + defaultGroup.setOrder(order.getAndIncrement()); + groups.forEach(group -> { + + ApiDoc groupApiDoc = ApiDoc.buildGroupApiDoc(group.getName()); + groupApiDoc.setOrder(order.getAndIncrement()); + finalApiDocs.add(groupApiDoc); + apiDocList.forEach(doc -> { + + if (!DocUtil.isMatch(group.getApis(), doc.getPackageName())) { + defaultGroup.getChildrenApiDocs().add(doc); + doc.setOrder(defaultGroup.getChildrenApiDocs().size()); + return; + } + groupApiDoc.getChildrenApiDocs().add(doc); + doc.setOrder(groupApiDoc.getChildrenApiDocs().size()); + doc.setGroup(group.getName()); + if (StringUtil.isEmpty(group.getPaths())) { + return; + } + List methodDocs = doc.getList().stream() + .filter(l -> DocPathUtil.matches(l.getPath(), group.getPaths(), null)) + .collect(Collectors.toList()); + doc.setList(methodDocs); + }); + }); + + return finalApiDocs; + } + + default List buildReturnApiParams(DocJavaMethod docJavaMethod, ProjectDocConfigBuilder projectBuilder) { JavaMethod method = docJavaMethod.getJavaMethod(); if (method.getReturns().isVoid() && Objects.isNull(projectBuilder.getApiConfig().getResponseBodyAdvice())) { diff --git a/src/main/resources/template/AllInOne.adoc b/src/main/resources/template/AllInOne.adoc index 319ec70..ac7f46e 100644 --- a/src/main/resources/template/AllInOne.adoc +++ b/src/main/resources/template/AllInOne.adoc @@ -17,26 +17,30 @@ for(revisionLog in revisionLogList){ <% -for(api in apiDocList){ +for(apiGroup in apiDocList){ %> -== ${api.desc} +== ${apiGroup.group} +<% +for(api in apiGroup.childrenApiDocs){ +%> +=== ${api.desc} <% for(doc in api.list){ %> <%if(doc.deprecated){%> -=== [line-through]#${doc.desc}# +==== [line-through]#${doc.desc}# <%}else{%> -=== ${doc.desc} +==== ${doc.desc} <%}%> -*URL:* ${doc.url} +*URL:* `${doc.url}` -*Type:* ${doc.type} +*Type:* `${doc.type}` <%if(isNotEmpty(doc.author)){%> *Author:* ${doc.author} <%}%> -*Content-Type:* ${doc.contentType} +*Content-Type:* `${doc.contentType}` <%if(isNotEmpty(doc.headers)){%> *Request-headers:* @@ -122,6 +126,7 @@ ${doc.responseUsage} ---- <%}%> +<% } %> <% } %> <% } %> <%if(isNotEmpty(errorCodeList)){%> diff --git a/src/main/resources/template/AllInOne.btl b/src/main/resources/template/AllInOne.btl index 18ea36d..b565da4 100644 --- a/src/main/resources/template/AllInOne.btl +++ b/src/main/resources/template/AllInOne.btl @@ -14,7 +14,11 @@ ${revisionLog.version}|${revisionLog.revisionTime}|${revisionLog.status}|${revis <% -for(api in apiDocList){ +for(apiGroup in apiDocList){ +%> +# ${apiGroup.group} +<% +for(api in apiGroup.childrenApiDocs){ %> ## ${api.desc} <% @@ -106,6 +110,7 @@ ${doc.responseUsage} ``` <%}%> +<% } %> <% } %> <% } %> <%if(isNotEmpty(errorCodeList)){%> diff --git a/src/main/resources/template/debug-all.html b/src/main/resources/template/debug-all.html index 1e86df6..c624aac 100644 --- a/src/main/resources/template/debug-all.html +++ b/src/main/resources/template/debug-all.html @@ -1,30 +1,492 @@ -<%if(isNotEmpty(projectName)){%>${projectName}<%}else{%>API Reference<%}%>
<%if(isNotEmpty(revisionLogList)){%>
<%for(revisionLog in revisionLogList){%><%}%>
VersionUpdate TimeStatusAuthorDescription

${revisionLog.version}

${revisionLog.revisionTime}

${revisionLog.status}

${revisionLog.author}

${revisionLog.remarks}

<%}%><%for(api in apiDocList){%>

${api.order}. ${htmlEscape(api.desc)}

<%for(doc in api.list){%>

<%if(doc.deprecated){%>${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}else{%>${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}%>

Type: ${doc.type}

<%if(isNotEmpty(doc.author)){%>

Author:  ${doc.author}

<%}%>

Content-Type: ${doc.contentType}

Description:  ${htmlEscape(doc.detail)}

<%if(isNotEmpty(doc.requestHeaders)){%>

Request-headers:

<%for(header in doc.requestHeaders){%><%}%>
HeaderValueTypeRequiredDescription

${header.name}

${header.type}

${header.required}

${htmlEscape(header.desc)}

<%}%><%if(isNotEmpty(doc.pathParams)){%>

Path-parameters:

<%for(param in doc.pathParams){%><%}%>
Parameter ValueTypeRequiredDescription

${param.field}

${param.type}

${param.required}

${htmlEscape(param.desc)}

<%}%><%if(isNotEmpty(doc.queryParams)){%>

Query-parameters:

<%for(param in doc.queryParams){%><%if(param.version !='-' ){%><%}else{%><%}%><%}%>
ParameterValueTypeRequiredDescription

${param.field}

<%if(param.type=="file"){%><%}else{%><%}%>

${param.type}

${param.required}

${htmlEscape(param.desc)}@since ${param.version}

${htmlEscape(param.desc)}

<%}%><%if(isNotEmpty(doc.requestParams)){%>

Body-parameters:

<%for(param in doc.requestParams){%><%if(param.version !='-' ){%><%}else{%><%}%><%}%>
ParameterTypeRequiredDescription

${param.field}

${param.type}

${param.required}

${htmlEscape(param.desc)}@since ${param.version}

${htmlEscape(param.desc)}

<%}%><%if(isNotEmpty(doc.requestExample.jsonBody)&&isRequestExample){%>

Request-body:

${doc.requestExample.jsonBody}
<%}%><%if(isNotEmpty(doc.responseParams)){%>

Response-fields:

<%for(param in doc.responseParams){%><%}%>
FieldTypeDescriptionSince

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.version}

<%}%>

<%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%>

Response-example:

${doc.responseUsage}
<%}%><%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%>

Curl-example:

${doc.requestUsage}
<%}%>
<%}%>
<%}%><%if(isNotEmpty(errorCodeList)){%>

${apiDocList.~size+1}. ${errorListTitle}

<%for(error in errorCodeList){%><%}%>
Error codeDescription

${error.value}

${htmlEscape(error.desc)}

<%}%><%if(isNotEmpty(dictList)){%>

${dictListOrder}. ${dictListTitle}

<%for(dict in dictList){%>

${dictListOrder}.${dict.order}. ${htmlEscape(dict.title)}

<%for(dataDict in dict.dataDictList){%><%}%>
CodeTypeDescription

${dataDict.value}

${dataDict.type}

${htmlEscape(dataDict.desc)}

<%}%>
<%}%>
Generated by smart-doc at ${createTime}Suggestions,contact,support and error reporting on Gitee or Github
Top
- - - + + + + +
<%if(isNotEmpty(revisionLogList)){%> +
+
+ + + + + + + + + + + + + + + + + + <%for(revisionLog in revisionLogList){%> + + + + + + + + <%}%> + +
VersionUpdate TimeStatusAuthorDescription

+ ${revisionLog.version}

+ ${revisionLog.revisionTime}

+ ${revisionLog.status}

+ ${revisionLog.author}

+ ${revisionLog.remarks}

+
+
+ <%}%> + <%for(apiGroup in apiDocList){%> + <%for(api in apiGroup.childrenApiDocs){%> +

${api.order}. ${htmlEscape(api.desc)} +

+
<%for(doc in api.list){%> +

<%if(doc.deprecated){%>${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}else{%>${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}%> +

+ +

+ Type: ${doc.type}

+ <%if(isNotEmpty(doc.author)){%> +

Author:  ${doc.author}

+ <%}%> +
+

Content-Type: ${doc.contentType}

+

Description:  ${htmlEscape(doc.detail)}

+
+ <%if(isNotEmpty(doc.requestHeaders)){%> +

Request-headers:

+ + + + + + + + + + + + + + + + + + + + <%for(header in doc.requestHeaders){%> + + + + + + + + + <%}%> + +
+
+
HeaderValueTypeRequiredDescription
+
+

${header.name}

+

${header.type}

+

+ ${header.required}

+ ${htmlEscape(header.desc)}

+ <%}%><%if(isNotEmpty(doc.pathParams)){%> +

Path-parameters:

+ + + + + + + + + + + + + + + + + + + + <%for(param in doc.pathParams){%> + + + + + + + + + <%}%> + +
+
+
Parameter ValueTypeRequiredDescription
+
+

${param.field}

+

${param.type}

+

+ ${param.required}

+ ${htmlEscape(param.desc)}

+ <%}%><%if(isNotEmpty(doc.queryParams)){%> +

Query-parameters:

+ + + + + + + + + + + + + + + + + + + + <%for(param in doc.queryParams){%> + + + + + + + <%if(param.version !='-' ){%> + + <%}else{%> + + <%}%> + + <%}%> + +
+
+
ParameterValueTypeRequiredDescription
+
+

${param.field}

+

+ <%if(param.type=="file"){%><%}else{%><%}%>

${param.type}

+

+ ${param.required}

+ ${htmlEscape(param.desc)}@since ${param.version}

+ ${htmlEscape(param.desc)}

+ <%}%><%if(isNotEmpty(doc.requestParams)){%> +

Body-parameters:

+ + + + + + + + + + + + + + + + <%for(param in doc.requestParams){%> + + + + + <%if(param.version !='-' ){%> + + <%}else{%> + + <%}%> + + <%}%> + +
ParameterTypeRequiredDescription

${param.field}

+

${param.type}

+

+ ${param.required}

+ ${htmlEscape(param.desc)}@since ${param.version}

+ ${htmlEscape(param.desc)}

+ <%}%><%if(isNotEmpty(doc.requestExample.jsonBody)&&isRequestExample){%> +

Request-body:

+
+
+
${doc.requestExample.jsonBody}
+
+
+ <%}%><%if(isNotEmpty(doc.responseParams)){%> +

Response-fields:

+ + + + + + + + + + + + + + + + <%for(param in doc.responseParams){%> + + + + + + + <%}%> + +
FieldTypeDescriptionSince

${param.field}

+

${param.type}

+

+ ${htmlEscape(param.desc)}

${param.version}

+
+ <%}%> +
+

+ +

+
+ <%if(isNotEmpty(doc.responseUsage)&&isResponseExample){%> +

Response-example:

+
+
+
${doc.responseUsage}
+
+
+ <%}%><%if(isNotEmpty(doc.requestUsage)&&isRequestExample){%> +

Curl-example:

+
+
+
${doc.requestUsage}
+
+
+ <%}%> +
+ <%}%> +
+
+ <%}%> + <%}%> + <%if(isNotEmpty(errorCodeList)){%> +

${apiDocList.~size+1}. ${errorListTitle} +

+
+ + + + + + + + + + + + <%for(error in errorCodeList){%> + + + + + <%}%> + +
Error codeDescription

${error.value}

+ ${htmlEscape(error.desc)}

+
+
+ <%}%><%if(isNotEmpty(dictList)){%> +

${dictListOrder}. ${dictListTitle} +

+
<%for(dict in dictList){%> +

+ ${dictListOrder}.${dict.order}. ${htmlEscape(dict.title)}

+ + + + + + + + + + + + + + <%for(dataDict in dict.dataDictList){%> + + + + + + <%}%> + +
CodeTypeDescription

+ ${dataDict.value}

${dataDict.type}

+

+ ${htmlEscape(dataDict.desc)}

+
+ <%}%> +
+
+ <%}%> +
Generated by smart-doc at ${createTime}Suggestions,contact,support and error reporting on Gitee or Github +
+
Top
+
+ + + - + }); + + \ No newline at end of file diff --git a/src/main/resources/template/js/search_all.js.btl b/src/main/resources/template/js/search_all.js.btl index d98e5ff..7942d91 100644 --- a/src/main/resources/template/js/search_all.js.btl +++ b/src/main/resources/template/js/search_all.js.btl @@ -1,6 +1,12 @@ let api = []; -<%for(api in apiDocList){%> +<%for(apiGroup in apiDocList) {%> api.push({ + name: '${apiGroup.group}', + order: '${apiGroup.order}', + list: [] +}) +<%for(api in apiGroup.childrenApiDocs) {%> +api[${apiGroupLP.dataIndex}].list.push({ alias: '${api.alias}', order: '${api.order}', link: '${removeLineBreaks(api.link)}', @@ -8,12 +14,13 @@ api.push({ list: [] }) <%for(doc in api.list) {%> -api[${apiLP.dataIndex}].list.push({ +api[${apiGroupLP.dataIndex}].list[${apiLP.dataIndex}].list.push({ order: '${doc.order}', desc: '${removeLineBreaks(doc.desc)}', }); <%}%> <%}%> +<%}%> document.onkeydown = keyDownSearch; function keyDownSearch(e) { const theEvent = e; @@ -21,38 +28,52 @@ function keyDownSearch(e) { if (code == 13) { const search = document.getElementById('search'); const searchValue = search.value; - let searchArr = []; + let searchGroup = []; for (let i = 0; i < api.length; i++) { - let apiData = api[i]; - const desc = apiData.desc; - if (desc.indexOf(searchValue) > -1) { - searchArr.push({ - order: apiData.order, - desc: apiData.desc, - link: apiData.link, - list: apiData.list - }); - } else { - let methodList = apiData.list || []; - let methodListTemp = []; - for (let j = 0; j < methodList.length; j++) { - const methodData = methodList[j]; - const methodDesc = methodData.desc; - if (methodDesc.indexOf(searchValue) > -1) { - methodListTemp.push(methodData); - break; - } - } - if (methodListTemp.length > 0) { - const data = { + + let apiGroup = api[i]; + + let searchArr = []; + for (let i = 0; i < apiGroup.list.length; i++) { + let apiData = apiGroup.list[i]; + const desc = apiData.desc; + if (desc.indexOf(searchValue) > -1) { + searchArr.push({ order: apiData.order, desc: apiData.desc, link: apiData.link, - list: methodListTemp - }; - searchArr.push(data); + list: apiData.list + }); + } else { + let methodList = apiData.list || []; + let methodListTemp = []; + for (let j = 0; j < methodList.length; j++) { + const methodData = methodList[j]; + const methodDesc = methodData.desc; + if (methodDesc.indexOf(searchValue) > -1) { + methodListTemp.push(methodData); + break; + } + } + if (methodListTemp.length > 0) { + const data = { + order: apiData.order, + desc: apiData.desc, + link: apiData.link, + list: methodListTemp + }; + searchArr.push(data); + } } } + if (searchArr.length === 0) { + continue; + } + searchGroup.push({ + name: apiGroup.name, + order: apiGroup.order, + list: searchArr + }); } let html; if (searchValue == '') { @@ -63,7 +84,7 @@ function keyDownSearch(e) { } else { const liClass = "open"; const display = "display: block"; - html = buildAccordion(searchArr,liClass,display); + html = buildAccordion(searchGroup,liClass,display); document.getElementById('accordion').innerHTML = html; } const Accordion = function (el, multiple) { @@ -85,18 +106,29 @@ function keyDownSearch(e) { } } -function buildAccordion(apiData, liClass, display) { +function buildAccordion(apiGroups, liClass, display) { let html = ""; let doc; - if (apiData.length > 0) { - for (let j = 0; j < apiData.length; j++) { + if (apiGroups.length > 0) { + for (let i = 0; i < apiGroups.length; i++) { + let apiGroup = apiGroups[i]; html += '
  • '; - html += '' + apiData[j].order + '. ' + apiData[j].desc + ''; - html += '
      '; - doc = apiData[j].list; - for (let m = 0; m < doc.length; m++) { - html += '
    • ' + apiData[j].order + '.' + doc[m].order + '. ' + doc[m].desc + '
    • '; + html += '' + apiGroup.order + '. ' + apiGroup.name + ''; + html += ''; html += ''; } diff --git a/src/test/java/com/power/doc/ApiDocTest.java b/src/test/java/com/power/doc/ApiDocTest.java index d1d794f..45e87ee 100644 --- a/src/test/java/com/power/doc/ApiDocTest.java +++ b/src/test/java/com/power/doc/ApiDocTest.java @@ -102,7 +102,7 @@ public class ApiDocTest { //OpenApiBuilder.buildOpenApi(config); HtmlApiDocBuilder.buildApiDoc(config); //RpcTornaBuilder.buildApiDoc(config); - TornaBuilder.buildApiDoc(config); +// TornaBuilder.buildApiDoc(config); // RpcHtmlBuilder.buildApiDoc(config); long end = System.currentTimeMillis(); DateTimeUtil.printRunTime(end, start);