-
Notifications
You must be signed in to change notification settings - Fork 8
/
DevHttpManager_READMEMain.java
112 lines (97 loc) · 4.03 KB
/
DevHttpManager_READMEMain.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package javadoc.dev_utils.readme;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import dev.utils.common.FileUtils;
import javadoc.dev_utils.ApiConfig;
import javadoc.dev_utils.assist.PackageCatalog;
/**
* detail: 创建 README Main 方法
* @author Ttt
*/
final class DevHttpManager_READMEMain {
private DevHttpManager_READMEMain() {
}
/**
* 创建 DevHttpManager - README 头部前缀
* @param builder 拼接 Builder
* @param path 文件路径
* @param packageName 包名
* @param mapCatalog 对应目录的注释
* @param templatePath Readme 模板路径
*/
private static void createREADMEHead(
final StringBuilder builder,
final String path,
final String packageName,
final HashMap<String, String> mapCatalog,
final String templatePath
) {
// 不增加锚链接 -> 一级目录
String catalog = PackageCatalog.apiCatalog(false, path, packageName, mapCatalog);
// template readme content
byte[] bytes = FileUtils.readFileBytes(templatePath);
String templateContent = new String(bytes);
// 保存 README 内容
builder.append(String.format(
templateContent, ApiConfig.DEV_HTTP_MANAGER_VERSION,
catalog
));
}
/**
* 创建 README 文件
* @return Create Result
*/
public static String createREADME() {
// 包名
final String packageName = ApiConfig.DEV_HTTP_MANAGER_PACKAGE;
// 本地文件路径
final String path = ApiConfig.DEV_HTTP_MANAGER_PATH;
// Github 链接地址
final String githubUrl = ApiConfig.DEV_HTTP_MANAGER_GITHUB_URL;
// 方法名匹配存储 Map<类名, List<方法名>>
final HashMap<String, List<String>> methodNameMatchesMap = new HashMap<>();
// 方法名重复记录存储
final StringBuilder methodRepeatBuilder = new StringBuilder();
// 方法没有注释记录存储
final StringBuilder methodNotAnnotateBuilder = new StringBuilder();
// 类不存在方法记录存储
final StringBuilder notMethodBuilder = new StringBuilder();
// ===========
// = 生成 API =
// ===========
// 最终的数据
StringBuilder builder = new StringBuilder();
// 添加头部信息
createREADMEHead(
builder, path, packageName, ApiConfig.sCatalogMap_HttpManager,
ApiConfig.DEV_HTTP_MANAGER_TEMPLATE
);
// 保存合成后的 API README
FileUtils.saveFile(
new File(
ApiConfig.DEV_HTTP_MANAGER_API_FILE_SAVE_PATH,
ApiConfig.README_FILE_NAME
).getAbsolutePath(), builder.toString().getBytes()
);
// // 方法名重复记录存储
// Utils.saveFile(ApiConfig.DEV_HTTP_MANAGER_API_FILE_SAVE_PATH, "readme_method_repeat_api.md", methodRepeatBuilder.toString());
// // 方法没有注释记录存储
// Utils.saveFile(ApiConfig.DEV_HTTP_MANAGER_API_FILE_SAVE_PATH, "readme_method_not_annotate_api.md", methodNotAnnotateBuilder.toString());
// // 类不存在方法记录存储
// Utils.saveFile(ApiConfig.DEV_HTTP_MANAGER_API_FILE_SAVE_PATH, "readme_not_method_api.md", notMethodBuilder.toString());
StringBuilder resultBuilder = new StringBuilder();
resultBuilder.append("\n");
resultBuilder.append("\n===================");
resultBuilder.append("\n= 保存 JavaDoc 成功 =");
resultBuilder.append("\n===================");
resultBuilder.append("\n");
resultBuilder.append("\n");
resultBuilder.append("保存地址: " + ApiConfig.DEV_HTTP_MANAGER_API_FILE_SAVE_PATH + ApiConfig.README_FILE_NAME);
resultBuilder.append("\n");
return resultBuilder.toString();
}
public static void main(String[] args) {
System.out.println(DevHttpManager_READMEMain.createREADME());
}
}