commit
7079427c9b
|
@ -71,6 +71,7 @@ public class AdocDocBuilder {
|
|||
} else {
|
||||
builderTemplate.buildApiDoc(apiDocList, config, API_DOC_ADOC_TPL, API_EXTENSION);
|
||||
builderTemplate.buildErrorCodeDoc(config, ERROR_CODE_LIST_ADOC_TPL, ERROR_CODE_LIST_ADOC);
|
||||
builderTemplate.buildDirectoryDataDoc(config, javaProjectBuilder, DICT_LIST_ADOC_TPL, DICT_LIST_ADOC);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ public class ApiDocBuilder {
|
|||
} else {
|
||||
builderTemplate.buildApiDoc(apiDocList, config, API_DOC_MD_TPL, API_EXTENSION);
|
||||
builderTemplate.buildErrorCodeDoc(config, ERROR_CODE_LIST_MD_TPL, ERROR_CODE_LIST_MD);
|
||||
builderTemplate.buildDirectoryDataDoc(config, javaProjectBuilder, DICT_LIST_MD_TPL, DICT_LIST_MD);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,18 +143,7 @@ public class DocBuilderTemplate {
|
|||
} else {
|
||||
tpl.binding(TemplateVariable.DICT_ORDER.getVariable(), apiDocList.size() + 2);
|
||||
}
|
||||
if (null != config.getLanguage()) {
|
||||
if (DocLanguage.CHINESE.code.equals(config.getLanguage().getCode())) {
|
||||
tpl.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_CN_TITLE);
|
||||
tpl.binding(TemplateVariable.DICT_LIST_TITLE.getVariable(), DocGlobalConstants.DICT_CN_TITLE);
|
||||
} else {
|
||||
tpl.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_EN_TITLE);
|
||||
tpl.binding(TemplateVariable.DICT_LIST_TITLE.getVariable(), DocGlobalConstants.DICT_EN_TITLE);
|
||||
}
|
||||
} else {
|
||||
tpl.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_CN_TITLE);
|
||||
tpl.binding(TemplateVariable.DICT_LIST_TITLE.getVariable(), DocGlobalConstants.DICT_CN_TITLE);
|
||||
}
|
||||
setDirectoryLanguageVariable(config, tpl);
|
||||
List<ApiDocDict> apiDocDictList = buildDictionary(config, javaProjectBuilder);
|
||||
tpl.binding(TemplateVariable.DICT_LIST.getVariable(), apiDocDictList);
|
||||
FileUtil.nioWriteFile(tpl.render(), outPath + FILE_SEPARATOR + outPutFileName);
|
||||
|
@ -175,6 +164,36 @@ public class DocBuilderTemplate {
|
|||
FileUtil.nioWriteFile(mapper.render(), config.getOutPath() + FILE_SEPARATOR + outPutFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* build common_data doc
|
||||
*
|
||||
* @param config api config
|
||||
* @param template template
|
||||
* @param outPutFileName output file
|
||||
*/
|
||||
public void buildDirectoryDataDoc(ApiConfig config, JavaProjectBuilder javaProjectBuilder, String template, String outPutFileName) {
|
||||
List<ApiDocDict> directoryList = buildDictionary(config, javaProjectBuilder);
|
||||
Template mapper = BeetlTemplateUtil.getByName(template);
|
||||
setDirectoryLanguageVariable(config, mapper);
|
||||
mapper.binding(TemplateVariable.DICT_LIST.getVariable(), directoryList);
|
||||
FileUtil.nioWriteFile(mapper.render(), config.getOutPath() + FILE_SEPARATOR + outPutFileName);
|
||||
}
|
||||
|
||||
private void setDirectoryLanguageVariable(ApiConfig config, Template mapper) {
|
||||
if (null != config.getLanguage()) {
|
||||
if (DocLanguage.CHINESE.code.equals(config.getLanguage().getCode())) {
|
||||
mapper.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_CN_TITLE);
|
||||
mapper.binding(TemplateVariable.DICT_LIST_TITLE.getVariable(), DocGlobalConstants.DICT_CN_TITLE);
|
||||
} else {
|
||||
mapper.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_EN_TITLE);
|
||||
mapper.binding(TemplateVariable.DICT_LIST_TITLE.getVariable(), DocGlobalConstants.DICT_EN_TITLE);
|
||||
}
|
||||
} else {
|
||||
mapper.binding(TemplateVariable.ERROR_LIST_TITLE.getVariable(), DocGlobalConstants.ERROR_CODE_LIST_CN_TITLE);
|
||||
mapper.binding(TemplateVariable.DICT_LIST_TITLE.getVariable(), DocGlobalConstants.DICT_CN_TITLE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a single controller api document
|
||||
*
|
||||
|
|
|
@ -37,8 +37,14 @@ public interface DocGlobalConstants {
|
|||
|
||||
String ERROR_CODE_LIST_ADOC = "ErrorCodeList.md";
|
||||
|
||||
String DICT_LIST_MD = "Dictionary.md";
|
||||
|
||||
String DICT_LIST_MD_TPL = "Dictionary.btl";
|
||||
|
||||
String DICT_LIST_ADOC = "Dictionary.adoc";
|
||||
|
||||
String DICT_LIST_ADOC_TPL = "Dictionary.btl";
|
||||
|
||||
String INDEX_TPL = "Index.btl";
|
||||
|
||||
String INDEX_CSS_TPL = "index.css";
|
||||
|
|
|
@ -124,9 +124,9 @@ public class ParamsBuildHelper {
|
|||
an:
|
||||
for (JavaAnnotation annotation : javaAnnotations) {
|
||||
String simpleAnnotationName = annotation.getType().getValue();
|
||||
if (DocAnnotationConstants.SHORT_JSON_IGNORE.equals(simpleAnnotationName) && isResp) {
|
||||
if (DocAnnotationConstants.SHORT_JSON_IGNORE.equals(simpleAnnotationName)) {
|
||||
continue out;
|
||||
} else if (DocAnnotationConstants.SHORT_JSON_FIELD.equals(simpleAnnotationName) && isResp) {
|
||||
} else if (DocAnnotationConstants.SHORT_JSON_FIELD.equals(simpleAnnotationName)) {
|
||||
if (null != annotation.getProperty(DocAnnotationConstants.SERIALIZE_PROP)) {
|
||||
if (Boolean.FALSE.toString().equals(annotation.getProperty(DocAnnotationConstants.SERIALIZE_PROP).toString())) {
|
||||
continue out;
|
||||
|
@ -134,7 +134,7 @@ public class ParamsBuildHelper {
|
|||
} else if (null != annotation.getProperty(DocAnnotationConstants.NAME_PROP)) {
|
||||
fieldName = StringUtil.removeQuotes(annotation.getProperty(DocAnnotationConstants.NAME_PROP).toString());
|
||||
}
|
||||
} else if (DocAnnotationConstants.SHORT_JSON_PROPERTY.equals(simpleAnnotationName) && isResp) {
|
||||
} else if (DocAnnotationConstants.SHORT_JSON_PROPERTY.equals(simpleAnnotationName)) {
|
||||
if (null != annotation.getProperty(DocAnnotationConstants.VALUE_PROP)) {
|
||||
fieldName = StringUtil.removeQuotes(annotation.getProperty(DocAnnotationConstants.VALUE_PROP).toString());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<%if(isNotEmpty(dictList)){%>
|
||||
# Data Dictionaries
|
||||
# ${dictListTitle!"Data Dictionaries"}
|
||||
<%
|
||||
for(dict in dictList){
|
||||
%>
|
||||
|
|
Loading…
Reference in New Issue