Fix #56.
This commit is contained in:
parent
f1c3608b7e
commit
d19732ad1c
|
@ -65,8 +65,8 @@ public class RpcDocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
mapper.binding(TemplateVariable.DESC.getVariable(), rpcDoc.getDesc());
|
||||
mapper.binding(TemplateVariable.NAME.getVariable(), rpcDoc.getName());
|
||||
mapper.binding(TemplateVariable.LIST.getVariable(), rpcDoc.getList());
|
||||
mapper.binding(TemplateVariable.PROTOCOL.getVariable(), rpcDoc.getProtocol());
|
||||
mapper.binding(TemplateVariable.AUTHOR.getVariable(), rpcDoc.getAuthor());
|
||||
mapper.binding(TemplateVariable.PROTOCOL.getVariable(), rpcDoc.getProtocol());
|
||||
mapper.binding(TemplateVariable.VERSION.getVariable(), rpcDoc.getVersion());
|
||||
mapper.binding(TemplateVariable.URI.getVariable(), rpcDoc.getUri());
|
||||
FileUtil.nioWriteFile(mapper.render(), config.getOutPath() + FILE_SEPARATOR + rpcDoc.getShortName() + fileExtension);
|
||||
|
@ -128,9 +128,9 @@ public class RpcDocBuilderTemplate extends BaseDocBuilderTemplate {
|
|||
*/
|
||||
public RpcApiAllData getApiData(ApiConfig config, JavaProjectBuilder javaProjectBuilder) {
|
||||
RpcApiAllData apiAllData = new RpcApiAllData();
|
||||
apiAllData.setLanguage(config.getLanguage().getCode());
|
||||
apiAllData.setProjectName(config.getProjectName());
|
||||
apiAllData.setProjectId(DocUtil.generateId(config.getProjectName()));
|
||||
apiAllData.setLanguage(config.getLanguage().getCode());
|
||||
apiAllData.setApiDocList(listOfApiData(config, javaProjectBuilder));
|
||||
apiAllData.setErrorCodeList(errorCodeDictToList(config));
|
||||
apiAllData.setRevisionLogs(config.getRevisionLogs());
|
||||
|
|
|
@ -148,10 +148,10 @@ public class RpcHtmlBuilder {
|
|||
apiTemplate.binding(TemplateVariable.DESC.getVariable(), rpcDoc.getDesc());
|
||||
apiTemplate.binding(TemplateVariable.NAME.getVariable(), rpcDoc.getName());
|
||||
apiTemplate.binding(TemplateVariable.LIST.getVariable(), rpcDoc.getList());
|
||||
apiTemplate.binding(TemplateVariable.PROTOCOL.getVariable(),rpcDoc.getProtocol());
|
||||
apiTemplate.binding(TemplateVariable.AUTHOR.getVariable(),rpcDoc.getAuthor());
|
||||
apiTemplate.binding(TemplateVariable.VERSION.getVariable(),rpcDoc.getVersion());
|
||||
apiTemplate.binding(TemplateVariable.URI.getVariable(),rpcDoc.getUri());
|
||||
apiTemplate.binding(TemplateVariable.PROTOCOL.getVariable(), rpcDoc.getProtocol());
|
||||
apiTemplate.binding(TemplateVariable.AUTHOR.getVariable(), rpcDoc.getAuthor());
|
||||
apiTemplate.binding(TemplateVariable.VERSION.getVariable(), rpcDoc.getVersion());
|
||||
apiTemplate.binding(TemplateVariable.URI.getVariable(), rpcDoc.getUri());
|
||||
|
||||
String html = MarkDownUtil.toHtml(apiTemplate.render());
|
||||
htmlApiDoc = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
|
@ -159,7 +159,7 @@ public class RpcHtmlBuilder {
|
|||
htmlApiDoc.binding(TemplateVariable.TITLE.getVariable(), rpcDoc.getDesc());
|
||||
htmlApiDoc.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime);
|
||||
htmlApiDoc.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
FileUtil.nioWriteFile(htmlApiDoc.render(), outPath + FILE_SEPARATOR + rpcDoc.getAlias() + ".html");
|
||||
FileUtil.nioWriteFile(htmlApiDoc.render(), outPath + FILE_SEPARATOR + rpcDoc.getShortName() + ".html");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -191,22 +191,25 @@ public class RpcHtmlBuilder {
|
|||
*/
|
||||
private static void buildDependency(ApiConfig config) {
|
||||
List<RpcApiDependency> apiDependencies = config.getRpcApiDependencies();
|
||||
Template template;
|
||||
if (CollectionUtil.isNotEmpty(config.getRpcApiDependencies())) {
|
||||
String rpcConfig = config.getRpcConsumerConfig();
|
||||
String rpcConfigConfigContent = null;
|
||||
if (Objects.nonNull(rpcConfig)) {
|
||||
rpcConfigConfigContent = FileUtil.getFileContent(rpcConfig);
|
||||
}
|
||||
Template template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_MD_TPL);
|
||||
template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_MD_TPL);
|
||||
template.binding(TemplateVariable.RPC_CONSUMER_CONFIG.getVariable(), rpcConfigConfigContent);
|
||||
template.binding(TemplateVariable.DEPENDENCY_LIST.getVariable(), apiDependencies);
|
||||
String dictHtml = MarkDownUtil.toHtml(template.render());
|
||||
Template dictTpl = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
dictTpl.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
dictTpl.binding(TemplateVariable.TITLE.getVariable(), DICT_EN_TITLE);
|
||||
dictTpl.binding(TemplateVariable.HTML.getVariable(), dictHtml);
|
||||
dictTpl.binding(TemplateVariable.CREATE_TIME.getVariable(), DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
FileUtil.nioWriteFile(dictTpl.render(), config.getOutPath() + FILE_SEPARATOR + "dependency.html");
|
||||
} else {
|
||||
template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_EMPTY_MD_TPL);
|
||||
}
|
||||
String dictHtml = MarkDownUtil.toHtml(template.render());
|
||||
Template dictTpl = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
dictTpl.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
dictTpl.binding(TemplateVariable.TITLE.getVariable(), DICT_EN_TITLE);
|
||||
dictTpl.binding(TemplateVariable.HTML.getVariable(), dictHtml);
|
||||
dictTpl.binding(TemplateVariable.CREATE_TIME.getVariable(), DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
FileUtil.nioWriteFile(dictTpl.render(), config.getOutPath() + FILE_SEPARATOR + "dependency.html");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class RpcMarkdownBuilder {
|
|||
List<RpcApiDoc> apiDocList = docBuildTemplate.getApiData(configBuilder);
|
||||
if (config.isAllInOne()) {
|
||||
String version = config.isCoverOld() ? "" : "-V" + DateTimeUtil.long2Str(System.currentTimeMillis(), DATE_FORMAT);
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, RPC_ALL_IN_ONE_MD_TPL, "DubboAllInOne" + version + ".md");
|
||||
builderTemplate.buildAllInOne(apiDocList, config, javaProjectBuilder, RPC_ALL_IN_ONE_MD_TPL, "rpc-all" + version + ".md");
|
||||
} else {
|
||||
builderTemplate.buildApiDoc(apiDocList, config, RPC_API_DOC_MD_TPL, API_EXTENSION);
|
||||
builderTemplate.buildErrorCodeDoc(config, ERROR_CODE_LIST_MD_TPL, ERROR_CODE_LIST_MD);
|
||||
|
|
|
@ -61,6 +61,8 @@ public interface DocGlobalConstants {
|
|||
|
||||
String RPC_DEPENDENCY_MD_TPL = "dubbo/DubboApiDependency.md";
|
||||
|
||||
String RPC_DEPENDENCY_EMPTY_MD_TPL = "dubbo/DubboApiDependencyEmpty.md";
|
||||
|
||||
String RPC_API_DOC_MD_TPL = "dubbo/Dubbo.md";
|
||||
|
||||
String RPC_ALL_IN_ONE_MD_TPL = "dubbo/DubboAllInOne.md";
|
||||
|
|
|
@ -59,7 +59,7 @@ public class JsonBuildHelper {
|
|||
return "This api return nothing.";
|
||||
}
|
||||
ApiReturn apiReturn = DocClassUtil.processReturnType(method.getReturnType().getGenericCanonicalName());
|
||||
String returnType = JavaClassUtil.javaTypeFormat(apiReturn.getGenericCanonicalName());
|
||||
String returnType = apiReturn.getGenericCanonicalName();
|
||||
String typeName = apiReturn.getSimpleName();
|
||||
return JsonFormatUtil.formatJson(buildJson(typeName, returnType, Boolean.TRUE, 0, new HashMap<>(), builder));
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public interface IDocBuildTemplate<T> {
|
|||
return null;
|
||||
}
|
||||
ApiReturn apiReturn = DocClassUtil.processReturnType(method.getReturnType().getGenericCanonicalName());
|
||||
String returnType = JavaClassUtil.javaTypeFormat(apiReturn.getGenericCanonicalName());
|
||||
String returnType = apiReturn.getGenericCanonicalName();
|
||||
String typeName = apiReturn.getSimpleName();
|
||||
if (this.ignoreReturnObject(typeName,projectBuilder.getApiConfig().getIgnoreRequestParams())) {
|
||||
return null;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package com.power.doc.template;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.power.common.util.StringUtil;
|
||||
import com.power.common.util.ValidateUtil;
|
||||
import com.power.doc.builder.ProjectDocConfigBuilder;
|
||||
|
@ -283,7 +282,7 @@ public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
|
|||
StringBuilder methodBuilder = new StringBuilder();
|
||||
JavaType returnType = method.getReturnType();
|
||||
String simpleReturn = returnType.getCanonicalName();
|
||||
String returnClass = JavaClassUtil.javaTypeFormat(returnType.getGenericCanonicalName());
|
||||
String returnClass = returnType.getGenericCanonicalName();
|
||||
returnClass = returnClass.replace(simpleReturn, JavaClassUtil.getClassSimpleName(simpleReturn));
|
||||
String[] arrays = DocClassUtil.getSimpleGicName(returnClass);
|
||||
for (String str : arrays) {
|
||||
|
@ -292,7 +291,14 @@ public class RpcDocBuildTemplate implements IDocBuildTemplate<RpcApiDoc> {
|
|||
}
|
||||
String[] generics = str.split("[<,]");
|
||||
for (String generic : generics) {
|
||||
returnClass = returnClass.replaceAll(generic, JavaClassUtil.getClassSimpleName(generic));
|
||||
if (generic.contains("extends")) {
|
||||
String className = generic.substring(generic.lastIndexOf(" ")+1);
|
||||
returnClass = returnClass.replace(className, JavaClassUtil.getClassSimpleName(className));
|
||||
}
|
||||
if (generic.length() != 1 && !generic.contains("extends")) {
|
||||
returnClass = returnClass.replaceAll(generic, JavaClassUtil.getClassSimpleName(generic));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
methodBuilder.append(returnClass).append(" ");
|
||||
|
|
|
@ -239,7 +239,7 @@ public class SpringBootDocBuildTemplate implements IDocBuildTemplate<ApiDoc> {
|
|||
JavaType javaType = parameter.getType();
|
||||
String paramName = parameter.getName();
|
||||
String typeName = javaType.getFullyQualifiedName();
|
||||
String gicTypeName = JavaClassUtil.javaTypeFormat(javaType.getGenericCanonicalName());
|
||||
String gicTypeName = javaType.getGenericCanonicalName();
|
||||
|
||||
String commentClass = paramsComments.get(paramName);
|
||||
//ignore request params
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# Add dependency
|
||||
|
||||
```
|
||||
<dependency>
|
||||
<groupId>Your api group</groupId>
|
||||
<artifactId>Your api artifactId</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Consumer config
|
||||
```
|
||||
dubbo:
|
||||
registry:
|
||||
protocol: zookeeper
|
||||
address: localhost:2181
|
||||
```
|
|
@ -24,17 +24,17 @@
|
|||
<%
|
||||
for(api in apiDocList){
|
||||
%>
|
||||
<li class="chapter " data-level="${api.alias}" data-path="${api.alias}.html">
|
||||
<a href="javascript:void(0)" onclick="go('${api.alias}', '${api.desc}');">${api.order+1} ${api.desc}</a>
|
||||
<li class="chapter " data-level="${api.shortName}" data-path="${api.shortName}.html">
|
||||
<a href="javascript:void(0)" onclick="go('${api.shortName}', '${api.desc}');">${api.order+1} ${api.desc}</a>
|
||||
<ul class="articles">
|
||||
<%
|
||||
for(doc in api.list){
|
||||
%>
|
||||
<li class="chapter " data-level="${api.alias}" data-path="${api.alias}.html">
|
||||
<li class="chapter " data-level="${api.shortName}" data-path="${api.shortName}.html">
|
||||
<%if(doc.deprecated){%>
|
||||
<a href="javascript:void(0)" onclick="go('${api.alias}', '${doc.desc}');">${api.order+1}.${doc.order} <span class="line-through">${doc.desc}</span></a></li>
|
||||
<a href="javascript:void(0)" onclick="go('${api.shortName}', '${doc.desc}');">${api.order+1}.${doc.order} <span class="line-through">${doc.desc}</span></a></li>
|
||||
<%}else{%>
|
||||
<a href="javascript:void(0)" onclick="go('${api.alias}', '${doc.desc}');">${api.order+1}.${doc.order} ${doc.desc}</a></li>
|
||||
<a href="javascript:void(0)" onclick="go('${api.shortName}', '${doc.desc}');">${api.order+1}.${doc.order} ${doc.desc}</a></li>
|
||||
<%}%>
|
||||
<%}%>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue