complete search
This commit is contained in:
parent
41d4f7f435
commit
c81b57b7b3
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
import static com.power.doc.constants.DocGlobalConstants.FILE_SEPARATOR;
|
||||
import static com.power.doc.constants.DocGlobalConstants.SEARCH_JS;
|
||||
import static com.power.doc.constants.DocGlobalConstants.SEARCH_JS_OUT;
|
||||
|
||||
/**
|
||||
* @author yu 2019/9/26.
|
||||
|
@ -186,7 +186,7 @@ public class DocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
apiDoc1.setList(methodDocs);
|
||||
apiDocs.add(apiDoc1);
|
||||
tpl.binding(TemplateVariable.API_DOC_LIST.getVariable(), apiDocs);
|
||||
FileUtil.nioWriteFile(tpl.render(), config.getOutPath() + FILE_SEPARATOR + SEARCH_JS);
|
||||
FileUtil.nioWriteFile(tpl.render(), config.getOutPath() + FILE_SEPARATOR + SEARCH_JS_OUT);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,10 +45,12 @@ public class HtmlApiDocBuilder {
|
|||
|
||||
private static long now = System.currentTimeMillis();
|
||||
|
||||
private static final String STR_TIME = DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND);
|
||||
|
||||
private static String INDEX_HTML = "index.html";
|
||||
|
||||
private static final String ERROR_CODE_HTML = "error.html";
|
||||
|
||||
private static final String DICT_HTML = "dict.html";
|
||||
|
||||
|
||||
/**
|
||||
* build controller api
|
||||
|
@ -81,28 +83,28 @@ public class HtmlApiDocBuilder {
|
|||
}
|
||||
if (config.isCreateDebugPage()) {
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, DEBUG_PAGE_ALL_TPL, DEBUG_PAGE_ALL_TPL);
|
||||
Template mockJs = BeetlTemplateUtil.getByName("js/mock.js");
|
||||
FileUtil.nioWriteFile(mockJs.render(), config.getOutPath() + FILE_SEPARATOR + "mock.js");
|
||||
Template mockJs = BeetlTemplateUtil.getByName(DEBUG_JS_TPL);
|
||||
FileUtil.nioWriteFile(mockJs.render(), config.getOutPath() + FILE_SEPARATOR + DEBUG_JS_OUT);
|
||||
} else {
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, ALL_IN_ONE_HTML_TPL, INDEX_HTML);
|
||||
}
|
||||
builderTemplate.buildSearchJs(config, javaProjectBuilder, apiDocList, "js/search_all.js.btl");
|
||||
builderTemplate.buildSearchJs(config, javaProjectBuilder, apiDocList, SEARCH_ALL_JS_TPL);
|
||||
} else {
|
||||
String indexAlias;
|
||||
if (config.isCreateDebugPage()) {
|
||||
indexAlias = "mock";
|
||||
indexAlias = "debug";
|
||||
buildDoc(builderTemplate, apiDocList, config, javaProjectBuilder, DEBUG_PAGE_SINGLE_TPL, indexAlias);
|
||||
Template mockJs = BeetlTemplateUtil.getByName("js/mock.js");
|
||||
FileUtil.nioWriteFile(mockJs.render(), config.getOutPath() + FILE_SEPARATOR + "mock.js");
|
||||
Template mockJs = BeetlTemplateUtil.getByName(DEBUG_JS_TPL);
|
||||
FileUtil.nioWriteFile(mockJs.render(), config.getOutPath() + FILE_SEPARATOR + DEBUG_JS_OUT);
|
||||
} else {
|
||||
indexAlias = "api";
|
||||
buildDoc(builderTemplate, apiDocList, config, javaProjectBuilder, SINGLE_INDEX_HTML_TPL, indexAlias);
|
||||
}
|
||||
builderTemplate.buildErrorCodeDoc(config, javaProjectBuilder, apiDocList, SINGLE_ERROR_HTML_TPL,
|
||||
"error.html", indexAlias);
|
||||
ERROR_CODE_HTML, indexAlias);
|
||||
builderTemplate.buildDirectoryDataDoc(config, javaProjectBuilder, apiDocList,
|
||||
SINGLE_DICT_HTML_TPL, "dict.html", indexAlias);
|
||||
builderTemplate.buildSearchJs(config, javaProjectBuilder, apiDocList, "js/search.js.btl");
|
||||
SINGLE_DICT_HTML_TPL, DICT_HTML, indexAlias);
|
||||
builderTemplate.buildSearchJs(config, javaProjectBuilder, apiDocList, SEARCH_JS_TPL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.Map;
|
|||
import java.util.Objects;
|
||||
|
||||
import static com.power.doc.constants.DocGlobalConstants.FILE_SEPARATOR;
|
||||
import static com.power.doc.constants.DocGlobalConstants.RPC_OUT_DIR;
|
||||
|
||||
/**
|
||||
* @author yu 2020/5/16.
|
||||
|
@ -55,6 +56,12 @@ public class RpcDocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
|
||||
private static final String DEPENDENCY_TITLE = "Add dependency";
|
||||
|
||||
|
||||
public void checkAndInit(ApiConfig config) {
|
||||
super.checkAndInit(config);
|
||||
config.setOutPath(config.getOutPath() + FILE_SEPARATOR + RPC_OUT_DIR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate api documentation for all controllers.
|
||||
*
|
||||
|
@ -106,7 +113,7 @@ public class RpcDocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
tpl.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime);
|
||||
tpl.binding(TemplateVariable.PROJECT_NAME.getVariable(), config.getProjectName());
|
||||
tpl.binding(TemplateVariable.RPC_CONSUMER_CONFIG.getVariable(), rpcConfigConfigContent);
|
||||
|
||||
setDirectoryLanguageVariable(config, tpl);
|
||||
FileUtil.nioWriteFile(tpl.render(), outPath + FILE_SEPARATOR + outPutFileName);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,6 @@ public class RpcHtmlBuilder {
|
|||
config.setShowJavaType(true);
|
||||
RpcDocBuilderTemplate builderTemplate = new RpcDocBuilderTemplate();
|
||||
builderTemplate.checkAndInit(config);
|
||||
builderTemplate.checkAndInit(config);
|
||||
ProjectDocConfigBuilder configBuilder = new ProjectDocConfigBuilder(config, javaProjectBuilder);
|
||||
RpcDocBuildTemplate docBuildTemplate = new RpcDocBuildTemplate();
|
||||
List<RpcApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
|
|
|
@ -6,6 +6,7 @@ package com.power.doc.constants;
|
|||
public interface DocGlobalConstants {
|
||||
|
||||
int API_ORDER = 0;
|
||||
|
||||
String FILE_SEPARATOR = System.getProperty("file.separator");
|
||||
|
||||
String HTML_DOC_OUT_PATH = "src/main/resources/static/doc";
|
||||
|
@ -46,20 +47,21 @@ public interface DocGlobalConstants {
|
|||
|
||||
String DICT_LIST_ADOC_TPL = "Dictionary.btl";
|
||||
|
||||
String INDEX_TPL = "Index.btl";
|
||||
String SEARCH_ALL_JS_TPL = "js/search_all.js.btl";
|
||||
|
||||
String INDEX_CSS_TPL = "index.css";
|
||||
String SEARCH_JS_TPL = "js/search.js.btl";
|
||||
|
||||
String MARKDOWN_CSS_TPL = "markdown.css";
|
||||
String SEARCH_JS_OUT = "search.js";
|
||||
|
||||
String SEARCH_JS = "search.js";
|
||||
String DEBUG_JS_TPL = "js/debug.js";
|
||||
|
||||
String DEBUG_JS_OUT = "debug.js";
|
||||
|
||||
String DEBUG_PAGE_TPL = "mock.html";
|
||||
|
||||
String DEBUG_PAGE_ALL_TPL = "debug-all.html";
|
||||
|
||||
String DEBUG_PAGE_ALL_TPL = "mock-all.html";
|
||||
|
||||
String DEBUG_PAGE_SINGLE_TPL = "html/mock.html";
|
||||
String DEBUG_PAGE_SINGLE_TPL = "html/debug.html";
|
||||
|
||||
String SINGLE_INDEX_HTML_TPL = "html/index.html";
|
||||
|
||||
|
@ -69,6 +71,8 @@ public interface DocGlobalConstants {
|
|||
|
||||
String ALL_IN_ONE_CSS = "AllInOne.css";
|
||||
|
||||
String RPC_OUT_DIR = "rpc";
|
||||
|
||||
String RPC_API_DOC_ADOC_TPL = "dubbo/Dubbo.adoc";
|
||||
|
||||
String RPC_ALL_IN_ONE_ADOC_TPL = "dubbo/DubboAllInOne.adoc";
|
||||
|
@ -168,6 +172,8 @@ public interface DocGlobalConstants {
|
|||
String EMPTY = "";
|
||||
|
||||
String ENUM = "enum";
|
||||
|
||||
String YAPI_RESULT_TPL = "yapiJson.btl";
|
||||
|
||||
String YAPI_JSON="/yapi.json";
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@ api[${apiLP.dataIndex}].list.push({
|
|||
<%}%>
|
||||
document.onkeydown = keyDownSearch;
|
||||
function keyDownSearch(e) {
|
||||
const theEvent = e || window.event;
|
||||
const theEvent = e;
|
||||
const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
||||
if (code == 13) {
|
||||
const search = document.getElementById('search');
|
||||
|
@ -56,11 +56,14 @@ function keyDownSearch(e) {
|
|||
}
|
||||
let html;
|
||||
if (searchValue == '') {
|
||||
html = buildAccordion(api);
|
||||
console.log(html);
|
||||
const liClass = "";
|
||||
const display = "display: none";
|
||||
html = buildAccordion(api,liClass,display);
|
||||
document.getElementById('accordion').innerHTML = html;
|
||||
} else {
|
||||
html = buildAccordion(searchArr);
|
||||
const liClass = "open";
|
||||
const display = "display: block";
|
||||
html = buildAccordion(searchArr,liClass,display);
|
||||
document.getElementById('accordion').innerHTML = html;
|
||||
}
|
||||
const Accordion = function (el, multiple) {
|
||||
|
@ -87,9 +90,9 @@ function buildAccordion(apiData) {
|
|||
let doc;
|
||||
if (apiData.length > 0) {
|
||||
for (let j = 0; j < apiData.length; j++) {
|
||||
html += '<li class="open">';
|
||||
html += '<li>';
|
||||
html += ' <a class="dd" href="#_' + apiData[j].link + '">' + apiData[j].order + '. ' + apiData[j].desc + '</a>';
|
||||
html += ' <ul class="sectlevel2" style="display: block">';
|
||||
html += ' <ul class="sectlevel2" style="display: none">';
|
||||
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>';
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -16,7 +16,7 @@ api[${apiLP.dataIndex}].list.push({
|
|||
<%}%>
|
||||
document.onkeydown = keyDownSearch;
|
||||
function keyDownSearch(e) {
|
||||
const theEvent = e || window.event;
|
||||
const theEvent = e;
|
||||
const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
||||
if (code == 13) {
|
||||
const search = document.getElementById('search');
|
||||
|
@ -58,11 +58,14 @@ function keyDownSearch(e) {
|
|||
}
|
||||
let html;
|
||||
if (searchValue == '') {
|
||||
html = buildAccordion(api);
|
||||
console.log(html);
|
||||
const liClass = "";
|
||||
const display = "display: none";
|
||||
html = buildAccordion(api,liClass,display);
|
||||
document.getElementById('accordion').innerHTML = html;
|
||||
} else {
|
||||
html = buildAccordion(searchArr);
|
||||
const liClass = "open";
|
||||
const display = "display: block";
|
||||
html = buildAccordion(searchArr,liClass,display);
|
||||
document.getElementById('accordion').innerHTML = html;
|
||||
}
|
||||
const Accordion = function (el, multiple) {
|
||||
|
@ -84,16 +87,16 @@ function keyDownSearch(e) {
|
|||
}
|
||||
}
|
||||
|
||||
function buildAccordion(apiData) {
|
||||
function buildAccordion(apiData, liClass, display) {
|
||||
let html = "";
|
||||
let doc;
|
||||
if (apiData.length > 0) {
|
||||
for (let j = 0; j < apiData.length; j++) {
|
||||
html += '<li class="open">';
|
||||
html += '<li class="'+liClass+'">';
|
||||
html += ' <a class="dd" href="' + apiData[j].alias + '.html#header">' + apiData[j].order + '. ' + apiData[j].desc + '</a>';
|
||||
html += ' <ul class="sectlevel2" style="display: block">';
|
||||
html += ' <ul class="sectlevel2" style="'+display+'">';
|
||||
doc = apiData[j].list;
|
||||
for (m = 0; m < doc.length; m++) {
|
||||
for (let m = 0; m < doc.length; m++) {
|
||||
html += '<li><a href="' + apiData[j].alias + '.html#_' + apiData[j].order + '_' + doc[m].order + '_' + doc[m].desc + '">' + apiData[j].order + '.' + doc[m].order + '. ' + doc[m].desc + '</a> </li>';
|
||||
}
|
||||
html += '</ul>';
|
||||
|
|
|
@ -16,7 +16,7 @@ api[${apiLP.dataIndex}].list.push({
|
|||
<%}%>
|
||||
document.onkeydown = keyDownSearch;
|
||||
function keyDownSearch(e) {
|
||||
const theEvent = e || window.event;
|
||||
const theEvent = e;
|
||||
const code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
||||
if (code == 13) {
|
||||
const search = document.getElementById('search');
|
||||
|
@ -56,11 +56,14 @@ function keyDownSearch(e) {
|
|||
}
|
||||
let html;
|
||||
if (searchValue == '') {
|
||||
html = buildAccordion(api);
|
||||
console.log(html);
|
||||
const liClass = "";
|
||||
const display = "display: none";
|
||||
html = buildAccordion(api,liClass,display);
|
||||
document.getElementById('accordion').innerHTML = html;
|
||||
} else {
|
||||
html = buildAccordion(searchArr);
|
||||
const liClass = "open";
|
||||
const display = "display: block";
|
||||
html = buildAccordion(searchArr,liClass,display);
|
||||
document.getElementById('accordion').innerHTML = html;
|
||||
}
|
||||
const Accordion = function (el, multiple) {
|
||||
|
@ -82,14 +85,14 @@ function keyDownSearch(e) {
|
|||
}
|
||||
}
|
||||
|
||||
function buildAccordion(apiData) {
|
||||
function buildAccordion(apiData, liClass, display) {
|
||||
let html = "";
|
||||
let doc;
|
||||
if (apiData.length > 0) {
|
||||
for (let j = 0; j < apiData.length; j++) {
|
||||
html += '<li class="open">';
|
||||
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: block">';
|
||||
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>';
|
||||
|
|
Loading…
Reference in New Issue