diff --git a/src/main/java/com/power/doc/builder/AdocDocBuilder.java b/src/main/java/com/power/doc/builder/AdocDocBuilder.java index f703f5e..28ef741 100644 --- a/src/main/java/com/power/doc/builder/AdocDocBuilder.java +++ b/src/main/java/com/power/doc/builder/AdocDocBuilder.java @@ -71,7 +71,7 @@ public class AdocDocBuilder { IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework()); List apiDocList = docBuildTemplate.getApiData(configBuilder); if (config.isAllInOne()) { - String docName = builderTemplate.allInOneDocName(config,INDEX_DOC,".doc"); + String docName = builderTemplate.allInOneDocName(config,INDEX_DOC,".adoc"); apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config); builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_ADOC_TPL, docName); } else { diff --git a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java index 90db409..8b0a0c8 100644 --- a/src/main/java/com/power/doc/builder/DocBuilderTemplate.java +++ b/src/main/java/com/power/doc/builder/DocBuilderTemplate.java @@ -162,22 +162,29 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate { apiDoc1.setOrder(apiDocs.size() + 1); apiDocs.add(apiDoc1); } + + boolean isOnlyDefaultGroup = apiDocList.size() == 1; + Map titleMap = setDirectoryLanguageVariable(config, tpl); // set error code if (CollectionUtil.isNotEmpty(errorCodeList)) { ApiDoc apiDoc1 = new ApiDoc(); - apiDoc1.setOrder(apiDocs.size() + 1); + apiDoc1.setOrder((isOnlyDefaultGroup ? apiDocs.get(0).getChildrenApiDocs().size() : apiDocs.size()) + 1); apiDoc1.setDesc(titleMap.get(TemplateVariable.ERROR_LIST_TITLE.getVariable())); apiDoc1.setList(new ArrayList<>(0)); apiDoc1.setLink("error_code_list"); apiDoc1.setAlias("error"); apiDoc1.setGroup(apiDoc1.getDesc()); - apiDocs.add(apiDoc1); + if (isOnlyDefaultGroup) { + apiDocs.get(0).getChildrenApiDocs().add(apiDoc1); + } else { + apiDocs.add(apiDoc1); + } } // set dict list List apiDocDictList = DocUtil.buildDictionary(config, javaProjectBuilder); ApiDoc apiDoc1 = new ApiDoc(); - apiDoc1.setOrder(apiDocs.size() + 1); + apiDoc1.setOrder((isOnlyDefaultGroup ? apiDocs.get(0).getChildrenApiDocs().size() : apiDocs.size()) + 1); apiDoc1.setLink("dict_list"); apiDoc1.setAlias("dict"); apiDoc1.setDesc(titleMap.get(TemplateVariable.DICT_LIST_TITLE.getVariable())); @@ -190,7 +197,11 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate { methodDocs.add(methodDoc); } apiDoc1.setList(methodDocs); - apiDocs.add(apiDoc1); + if (isOnlyDefaultGroup) { + apiDocs.get(0).getChildrenApiDocs().add(apiDoc1); + } else { + apiDocs.add(apiDoc1); + } tpl.binding(TemplateVariable.API_DOC_LIST.getVariable(), apiDocs); FileUtil.nioWriteFile(tpl.render(), config.getOutPath() + FILE_SEPARATOR + SEARCH_JS_OUT); } diff --git a/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java b/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java index 0f168ff..9b0a7ac 100644 --- a/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java +++ b/src/main/java/com/power/doc/builder/HtmlApiDocBuilder.java @@ -38,6 +38,7 @@ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.Reader; +import java.util.ArrayList; import java.util.List; import static com.power.doc.constants.DocGlobalConstants.*; @@ -78,10 +79,10 @@ public class HtmlApiDocBuilder { List apiDocList = docBuildTemplate.getApiData(configBuilder); Template indexCssTemplate = BeetlTemplateUtil.getByName(ALL_IN_ONE_CSS); FileUtil.nioWriteFile(indexCssTemplate.render(), config.getOutPath() + FILE_SEPARATOR + ALL_IN_ONE_CSS_OUT); - copyJarFile("js/"+HIGH_LIGHT_JS, config.getOutPath() + FILE_SEPARATOR + HIGH_LIGHT_JS); - copyJarFile("css/"+FONT_STYLE, config.getOutPath() + FILE_SEPARATOR + FONT_STYLE); - copyJarFile("js/"+JQUERY, config.getOutPath() + FILE_SEPARATOR + JQUERY); - copyJarFile("css/"+HIGH_LIGHT_STYLE, config.getOutPath() + FILE_SEPARATOR + HIGH_LIGHT_STYLE); + copyJarFile("js/" + HIGH_LIGHT_JS, config.getOutPath() + FILE_SEPARATOR + HIGH_LIGHT_JS); + copyJarFile("css/" + FONT_STYLE, config.getOutPath() + FILE_SEPARATOR + FONT_STYLE); + copyJarFile("js/" + JQUERY, config.getOutPath() + FILE_SEPARATOR + JQUERY); + copyJarFile("css/" + HIGH_LIGHT_STYLE, config.getOutPath() + FILE_SEPARATOR + HIGH_LIGHT_STYLE); if (config.isAllInOne()) { apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config); if (config.isCreateDebugPage()) { diff --git a/src/main/java/com/power/doc/builder/TornaBuilder.java b/src/main/java/com/power/doc/builder/TornaBuilder.java index 9395f39..0f23a95 100644 --- a/src/main/java/com/power/doc/builder/TornaBuilder.java +++ b/src/main/java/com/power/doc/builder/TornaBuilder.java @@ -30,6 +30,7 @@ import com.power.doc.constants.TornaConstants; import com.power.doc.factory.BuildTemplateFactory; import com.power.doc.model.ApiConfig; import com.power.doc.model.ApiDoc; +import com.power.doc.model.ApiGroup; import com.power.doc.model.torna.Apis; import com.power.doc.model.torna.TornaApi; import com.power.doc.model.torna.TornaDic; @@ -119,7 +120,8 @@ public class TornaBuilder { } tornaApi.setCommonErrorCodes(buildErrorCode(apiConfig)); - tornaApi.setApis(groupApiList); + // delete default group when only default group + tornaApi.setApis(groupApiList.size() == 1 ? groupApiList.get(0).getItems() : groupApiList); //Build push document information Map requestJson = TornaConstants.buildParams(PUSH, new Gson().toJson(tornaApi), apiConfig); //Push dictionary information diff --git a/src/main/resources/smart-doc-beetl.properties b/src/main/resources/smart-doc-beetl.properties index 4893fe1..3eb9dab 100644 --- a/src/main/resources/smart-doc-beetl.properties +++ b/src/main/resources/smart-doc-beetl.properties @@ -1,4 +1,6 @@ DELIMITER_STATEMENT_START=<% DELIMITER_STATEMENT_END=%> FN.htmlEscape = com.power.doc.function.HtmlEscape -FN.removeLineBreaks = com.power.doc.function.RemoveLineBreaks \ No newline at end of file +FN.removeLineBreaks = com.power.doc.function.RemoveLineBreaks +##?????? +FNP.strUtil = org.beetl.ext.fn.StringUtil \ No newline at end of file diff --git a/src/main/resources/template/AllInOne.html b/src/main/resources/template/AllInOne.html index efb8eaf..987723e 100644 --- a/src/main/resources/template/AllInOne.html +++ b/src/main/resources/template/AllInOne.html @@ -1,42 +1 @@ -<%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(apiGroup in apiDocList){%><%for(api in apiGroup.childrenApiDocs){%>

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

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

<%if(doc.deprecated){%>${apiGroup.order}.${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}else{%>${apiGroup.order}.${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)&&displayRequestParams){%>

Request-headers:

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

${header.name}

${header.type}

${htmlEscape(header.desc)}

${header.required}

${header.since}

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

Path-parameters:

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

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.required}

${param.version}

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

Query-parameters:

<%for(param in doc.queryParams){%><%}%>
ParameterTypeDescriptionRequiredSince

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.required}

${param.version}

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

Body-parameters:

<%for(param in doc.requestParams){%><%}%>
ParameterTypeDescriptionRequiredSince

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.required}

${param.version}

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

Request-example:

${doc.requestUsage}
<%}%><%if(isNotEmpty(doc.responseParams)&&displayResponseParams){%>

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(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 +<%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(apiGroup in apiDocList){%><% if (apiGroupLP.size > 1) {%>

${apiGroup.order}. ${htmlEscape(apiGroup.name)}

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

<% if (apiGroupLP.size > 1) {%> ${apiGroup.order}.${api.order}. ${htmlEscape(api.desc)}<%} else {%> ${api.order}. ${htmlEscape(api.desc)}<%}%>

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

<%if(doc.deprecated){%><% if (apiGroupLP.size > 1) {%> ${apiGroup.order}.${api.order}.${doc.order}. <%} else {%> ${api.order}.${doc.order}. <%}%>${htmlEscape(doc.desc)}<%}else{%><% if (apiGroupLP.size > 1) {%> ${apiGroup.order}.${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)&&displayRequestParams){%>

Request-headers:

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

${header.name}

${header.type}

${htmlEscape(header.desc)}

${header.required}

${header.since}

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

Path-parameters:

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

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.required}

${param.version}

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

Query-parameters:

<%for(param in doc.queryParams){%><%}%>
ParameterTypeDescriptionRequiredSince

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.required}

${param.version}

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

Body-parameters:

<%for(param in doc.requestParams){%><%}%>
ParameterTypeDescriptionRequiredSince

${param.field}

${param.type}

${htmlEscape(param.desc)}

${param.required}

${param.version}

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

Request-example:

${doc.requestUsage}
<%}%><%if(isNotEmpty(doc.responseParams)&&displayResponseParams){%>

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(errorCodeList)){%>

${apiDocList.~size == 1 ? apiDocList[0].childrenApiDocs.~size+1 : apiDocList.~size+1}. ${errorListTitle}

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

${error.value}

${htmlEscape(error.desc)}

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

${apiDocList.~size == 1 ? apiDocList[0].childrenApiDocs.~size+1 : 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/debug-all.html b/src/main/resources/template/debug-all.html index 67ede32..dddffdc 100644 --- a/src/main/resources/template/debug-all.html +++ b/src/main/resources/template/debug-all.html @@ -1,29 +1 @@ -<%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(apiGroup in apiDocList){%><%for(api in apiGroup.childrenApiDocs){%>

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

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

<%if(doc.deprecated){%>${apiGroup.order}.${api.order}.${doc.order}. ${htmlEscape(doc.desc)}<%}else{%>${apiGroup.order}.${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)&&displayRequestParams){%>

Request-headers:

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

${header.name}

${header.type}

${header.required}

${htmlEscape(header.desc)}

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

Path-parameters:

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

${param.field}

${param.type}

${param.required}

${htmlEscape(param.desc)}

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

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)&&displayRequestParams){%>

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)&&displayResponseParams){%>

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 +<%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(apiGroup in apiDocList){%><% if (apiGroupLP.size > 1) {%>

${apiGroup.order}. ${htmlEscape(apiGroup.name)}

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

<% if (apiGroupLP.size > 1) {%> ${apiGroup.order}.${api.order}. ${htmlEscape(api.desc)}<%} else {%> ${api.order}. ${htmlEscape(api.desc)}<%}%>

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

<%if(doc.deprecated){%><% if (apiGroupLP.size > 1) {%> ${apiGroup.order}.${api.order}.${doc.order}. <%} else {%> ${api.order}.${doc.order}. <%}%>${htmlEscape(doc.desc)}<%}else{%><% if (apiGroupLP.size > 1) {%> ${apiGroup.order}.${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)&&displayRequestParams){%>

Request-headers:

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

${header.name}

${header.type}

${header.required}

${htmlEscape(header.desc)}

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

Path-parameters:

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

${param.field}

${param.type}

${param.required}

${htmlEscape(param.desc)}

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

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)&&displayRequestParams){%>

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)&&displayResponseParams){%>

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 ? apiDocList[0].childrenApiDocs.~size+1 : apiDocList.~size+1}. ${errorListTitle}

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

${error.value}

${htmlEscape(error.desc)}

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

${apiDocList.~size == 1 ? apiDocList[0].childrenApiDocs.~size+1 : 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 7942d91..6ea731a 100644 --- a/src/main/resources/template/js/search_all.js.btl +++ b/src/main/resources/template/js/search_all.js.btl @@ -1,22 +1,23 @@ let api = []; +const apiDocListSize = ${apiDocList.~size} <%for(apiGroup in apiDocList) {%> api.push({ - name: '${apiGroup.group}', + name: '${strUtil.replace(apiGroup.group, "\'", "\\'")}', order: '${apiGroup.order}', list: [] }) <%for(api in apiGroup.childrenApiDocs) {%> api[${apiGroupLP.dataIndex}].list.push({ - alias: '${api.alias}', + alias: '${strUtil.replace(api.alias, "\'", "\\'")}', order: '${api.order}', - link: '${removeLineBreaks(api.link)}', - desc: '${removeLineBreaks(api.desc)}', + link: '${strUtil.replace(removeLineBreaks(api.link), "\'", "\\'")}', + desc: '${strUtil.replace(removeLineBreaks(api.desc), "\'", "\\'")}', list: [] }) <%for(doc in api.list) {%> api[${apiGroupLP.dataIndex}].list[${apiLP.dataIndex}].list.push({ order: '${doc.order}', - desc: '${removeLineBreaks(doc.desc)}', + desc: '${strUtil.replace(removeLineBreaks(doc.desc), "\'", "\\'")}', }); <%}%> <%}%> @@ -66,6 +67,14 @@ function keyDownSearch(e) { } } } + if (apiGroup.name.indexOf(searchValue) > -1) { + searchGroup.push({ + name: apiGroup.name, + order: apiGroup.order, + list: searchArr + }); + continue; + } if (searchArr.length === 0) { continue; } @@ -110,13 +119,8 @@ function buildAccordion(apiGroups, liClass, display) { let html = ""; let doc; if (apiGroups.length > 0) { - for (let i = 0; i < apiGroups.length; i++) { - let apiGroup = apiGroups[i]; - html += '
  • '; - html += '' + apiGroup.order + '. ' + apiGroup.name + ''; - html += '
      '; - - let apiData = apiGroup.list; + if (apiDocListSize == 1) { + let apiData = apiGroups[0].list; for (let j = 0; j < apiData.length; j++) { html += '
    • '; html += '' + apiData[j].order + '. ' + apiData[j].desc + ''; @@ -128,9 +132,29 @@ function buildAccordion(apiGroups, liClass, display) { html += '
    '; html += '
  • '; } + } else { + for (let i = 0; i < apiGroups.length; i++) { + let apiGroup = apiGroups[i]; + html += '
  • '; + html += '' + apiGroup.order + '. ' + apiGroup.name + ''; + html += '
      '; - html += '
    '; - html += '
  • '; + let apiData = apiGroup.list; + for (let j = 0; j < apiData.length; j++) { + html += '
  • '; + html += '' + apiData[j].order + '. ' + apiData[j].desc + ''; + html += ''; + html += '
  • '; + } + + html += ''; + html += ''; + } } } return html;