Merge pull request #150 from chenqi146/dev
[fix] 🐛 fix group search in html
This commit is contained in:
commit
04a253b3d1
|
@ -71,7 +71,7 @@ public class AdocDocBuilder {
|
||||||
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
IDocBuildTemplate docBuildTemplate = BuildTemplateFactory.getDocBuildTemplate(config.getFramework());
|
||||||
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
List<ApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||||
if (config.isAllInOne()) {
|
if (config.isAllInOne()) {
|
||||||
String docName = builderTemplate.allInOneDocName(config,INDEX_DOC,".doc");
|
String docName = builderTemplate.allInOneDocName(config,INDEX_DOC,".adoc");
|
||||||
apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config);
|
apiDocList = docBuildTemplate.handleApiGroup(apiDocList, config);
|
||||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_ADOC_TPL, docName);
|
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_ADOC_TPL, docName);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -162,22 +162,29 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
||||||
apiDoc1.setOrder(apiDocs.size() + 1);
|
apiDoc1.setOrder(apiDocs.size() + 1);
|
||||||
apiDocs.add(apiDoc1);
|
apiDocs.add(apiDoc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isOnlyDefaultGroup = apiDocList.size() == 1;
|
||||||
|
|
||||||
Map<String, String> titleMap = setDirectoryLanguageVariable(config, tpl);
|
Map<String, String> titleMap = setDirectoryLanguageVariable(config, tpl);
|
||||||
// set error code
|
// set error code
|
||||||
if (CollectionUtil.isNotEmpty(errorCodeList)) {
|
if (CollectionUtil.isNotEmpty(errorCodeList)) {
|
||||||
ApiDoc apiDoc1 = new ApiDoc();
|
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.setDesc(titleMap.get(TemplateVariable.ERROR_LIST_TITLE.getVariable()));
|
||||||
apiDoc1.setList(new ArrayList<>(0));
|
apiDoc1.setList(new ArrayList<>(0));
|
||||||
apiDoc1.setLink("error_code_list");
|
apiDoc1.setLink("error_code_list");
|
||||||
apiDoc1.setAlias("error");
|
apiDoc1.setAlias("error");
|
||||||
apiDoc1.setGroup(apiDoc1.getDesc());
|
apiDoc1.setGroup(apiDoc1.getDesc());
|
||||||
|
if (isOnlyDefaultGroup) {
|
||||||
|
apiDocs.get(0).getChildrenApiDocs().add(apiDoc1);
|
||||||
|
} else {
|
||||||
apiDocs.add(apiDoc1);
|
apiDocs.add(apiDoc1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// set dict list
|
// set dict list
|
||||||
List<ApiDocDict> apiDocDictList = DocUtil.buildDictionary(config, javaProjectBuilder);
|
List<ApiDocDict> apiDocDictList = DocUtil.buildDictionary(config, javaProjectBuilder);
|
||||||
ApiDoc apiDoc1 = new ApiDoc();
|
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.setLink("dict_list");
|
||||||
apiDoc1.setAlias("dict");
|
apiDoc1.setAlias("dict");
|
||||||
apiDoc1.setDesc(titleMap.get(TemplateVariable.DICT_LIST_TITLE.getVariable()));
|
apiDoc1.setDesc(titleMap.get(TemplateVariable.DICT_LIST_TITLE.getVariable()));
|
||||||
|
@ -190,7 +197,11 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
||||||
methodDocs.add(methodDoc);
|
methodDocs.add(methodDoc);
|
||||||
}
|
}
|
||||||
apiDoc1.setList(methodDocs);
|
apiDoc1.setList(methodDocs);
|
||||||
|
if (isOnlyDefaultGroup) {
|
||||||
|
apiDocs.get(0).getChildrenApiDocs().add(apiDoc1);
|
||||||
|
} else {
|
||||||
apiDocs.add(apiDoc1);
|
apiDocs.add(apiDoc1);
|
||||||
|
}
|
||||||
tpl.binding(TemplateVariable.API_DOC_LIST.getVariable(), apiDocs);
|
tpl.binding(TemplateVariable.API_DOC_LIST.getVariable(), apiDocs);
|
||||||
FileUtil.nioWriteFile(tpl.render(), config.getOutPath() + FILE_SEPARATOR + SEARCH_JS_OUT);
|
FileUtil.nioWriteFile(tpl.render(), config.getOutPath() + FILE_SEPARATOR + SEARCH_JS_OUT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import java.io.BufferedWriter;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.power.doc.constants.DocGlobalConstants.*;
|
import static com.power.doc.constants.DocGlobalConstants.*;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import com.power.doc.constants.TornaConstants;
|
||||||
import com.power.doc.factory.BuildTemplateFactory;
|
import com.power.doc.factory.BuildTemplateFactory;
|
||||||
import com.power.doc.model.ApiConfig;
|
import com.power.doc.model.ApiConfig;
|
||||||
import com.power.doc.model.ApiDoc;
|
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.Apis;
|
||||||
import com.power.doc.model.torna.TornaApi;
|
import com.power.doc.model.torna.TornaApi;
|
||||||
import com.power.doc.model.torna.TornaDic;
|
import com.power.doc.model.torna.TornaDic;
|
||||||
|
@ -119,7 +120,8 @@ public class TornaBuilder {
|
||||||
|
|
||||||
}
|
}
|
||||||
tornaApi.setCommonErrorCodes(buildErrorCode(apiConfig));
|
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
|
//Build push document information
|
||||||
Map<String, String> requestJson = TornaConstants.buildParams(PUSH, new Gson().toJson(tornaApi), apiConfig);
|
Map<String, String> requestJson = TornaConstants.buildParams(PUSH, new Gson().toJson(tornaApi), apiConfig);
|
||||||
//Push dictionary information
|
//Push dictionary information
|
||||||
|
|
|
@ -2,3 +2,5 @@ DELIMITER_STATEMENT_START=<%
|
||||||
DELIMITER_STATEMENT_END=%>
|
DELIMITER_STATEMENT_END=%>
|
||||||
FN.htmlEscape = com.power.doc.function.HtmlEscape
|
FN.htmlEscape = com.power.doc.function.HtmlEscape
|
||||||
FN.removeLineBreaks = com.power.doc.function.RemoveLineBreaks
|
FN.removeLineBreaks = com.power.doc.function.RemoveLineBreaks
|
||||||
|
##??????
|
||||||
|
FNP.strUtil = org.beetl.ext.fn.StringUtil
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,22 +1,23 @@
|
||||||
let api = [];
|
let api = [];
|
||||||
|
const apiDocListSize = ${apiDocList.~size}
|
||||||
<%for(apiGroup in apiDocList) {%>
|
<%for(apiGroup in apiDocList) {%>
|
||||||
api.push({
|
api.push({
|
||||||
name: '${apiGroup.group}',
|
name: '${strUtil.replace(apiGroup.group, "\'", "\\'")}',
|
||||||
order: '${apiGroup.order}',
|
order: '${apiGroup.order}',
|
||||||
list: []
|
list: []
|
||||||
})
|
})
|
||||||
<%for(api in apiGroup.childrenApiDocs) {%>
|
<%for(api in apiGroup.childrenApiDocs) {%>
|
||||||
api[${apiGroupLP.dataIndex}].list.push({
|
api[${apiGroupLP.dataIndex}].list.push({
|
||||||
alias: '${api.alias}',
|
alias: '${strUtil.replace(api.alias, "\'", "\\'")}',
|
||||||
order: '${api.order}',
|
order: '${api.order}',
|
||||||
link: '${removeLineBreaks(api.link)}',
|
link: '${strUtil.replace(removeLineBreaks(api.link), "\'", "\\'")}',
|
||||||
desc: '${removeLineBreaks(api.desc)}',
|
desc: '${strUtil.replace(removeLineBreaks(api.desc), "\'", "\\'")}',
|
||||||
list: []
|
list: []
|
||||||
})
|
})
|
||||||
<%for(doc in api.list) {%>
|
<%for(doc in api.list) {%>
|
||||||
api[${apiGroupLP.dataIndex}].list[${apiLP.dataIndex}].list.push({
|
api[${apiGroupLP.dataIndex}].list[${apiLP.dataIndex}].list.push({
|
||||||
order: '${doc.order}',
|
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) {
|
if (searchArr.length === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -110,6 +119,20 @@ function buildAccordion(apiGroups, liClass, display) {
|
||||||
let html = "";
|
let html = "";
|
||||||
let doc;
|
let doc;
|
||||||
if (apiGroups.length > 0) {
|
if (apiGroups.length > 0) {
|
||||||
|
if (apiDocListSize == 1) {
|
||||||
|
let apiData = apiGroups[0].list;
|
||||||
|
for (let j = 0; j < apiData.length; j++) {
|
||||||
|
html += '<li class="'+liClass+'">';
|
||||||
|
html += '<a class="dd" href="#_' + apiData[j].link + '">' + apiData[j].order + '. ' + apiData[j].desc + '</a>';
|
||||||
|
html += '<ul class="sectlevel2" style="'+display+'">';
|
||||||
|
doc = apiData[j].list;
|
||||||
|
for (let m = 0; m < doc.length; m++) {
|
||||||
|
html += '<li><a href="#_' + apiData[j].order + '_' + doc[m].order + '_' + doc[m].desc + '">' + apiData[j].order + '.' + doc[m].order + '. ' + doc[m].desc + '</a> </li>';
|
||||||
|
}
|
||||||
|
html += '</ul>';
|
||||||
|
html += '</li>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for (let i = 0; i < apiGroups.length; i++) {
|
for (let i = 0; i < apiGroups.length; i++) {
|
||||||
let apiGroup = apiGroups[i];
|
let apiGroup = apiGroups[i];
|
||||||
html += '<li class="'+liClass+'">';
|
html += '<li class="'+liClass+'">';
|
||||||
|
@ -133,5 +156,6 @@ function buildAccordion(apiGroups, liClass, display) {
|
||||||
html += '</li>';
|
html += '</li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
Loading…
Reference in New Issue