Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit87f6b61

Browse files
committed
Added kotlin support
1 parente13e70f commit87f6b61

File tree

2 files changed

+116
-112
lines changed

2 files changed

+116
-112
lines changed

‎pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<archive>
2727
<manifestEntries>
2828
<Main-Class>generatejavadoc.Main</Main-Class>
29-
<Built-By></Built-By>
30-
<Created-By></Created-By>
31-
<Build-Jdk></Build-Jdk>
29+
<Built-By/>
30+
<Created-By/>
31+
<Build-Jdk/>
3232
</manifestEntries>
3333
</archive>
3434
</configuration>

‎src/main/java/generatejavadoc/Main.java

Lines changed: 113 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
importjava.io.File;
66
importjava.io.IOException;
7-
importjava.nio.file.DirectoryStream;
8-
importjava.nio.file.Files;
9-
importjava.nio.file.Path;
10-
importjava.nio.file.Paths;
7+
importjava.nio.file.*;
118
importjava.util.ArrayList;
129
importjava.util.List;
1310
importjava.util.regex.Pattern;
@@ -44,114 +41,121 @@ public static void main(String[] args) throws IOException {
4441
ind++;
4542
finalbyte[]readmeMd =Files.readAllBytes(Paths.get(file.getAbsolutePath()));
4643
StringreadmeMdText =newString(readmeMd,UTF_8);
44+
PathMatchermatcher =FileSystems.getDefault().getPathMatcher("glob:*.{java,kt}");
4745
try (DirectoryStream<Path>dirStream =
4846
Files.newDirectoryStream(
49-
Paths.get(file.getAbsolutePath().replace("readme.md","")),"*.java")) {
47+
Paths.get(file.getAbsolutePath().replace("readme.md","")))) {
5048
for (Pathentry :dirStream) {
51-
FilejavaFile =entry.toFile();
52-
Pathpath =Paths.get(javaFile.getAbsolutePath());
53-
finalbyte[]solutionJava =Files.readAllBytes(path);
54-
StringsolutionJavaText =newString(solutionJava,UTF_8);
55-
int[]index = {0};
56-
String[]fromStr = {
57-
"(\"{{",
58-
"=\"{{",
59-
"\n- [",
60-
" board = [[",
61-
" grid = [[",
62-
" = [[",
63-
"**,",
64-
"**]",
65-
"(**",
66-
"**)",
67-
"[[]",
68-
"<code>",
69-
"</code>",
70-
"<sub>",
71-
"</sub>",
72-
"<sup>",
73-
"</sup>",
74-
"<ins>",
75-
"</ins>",
76-
"<",
77-
">",
78-
"&"
79-
};
80-
String[]fromStr2 = {
81-
"[code]","[/code]","[sub]","[/sub]","[sup]","[/sup]","[ins]",
82-
"[/ins]",
83-
};
84-
String[]toStr = {
85-
"(\"{ {",
86-
"=\"{ {",
87-
"\n-\\[",
88-
" board = [ [",
89-
" grid = [ [",
90-
" =\\[\\[",
91-
"** ,",
92-
"** ]",
93-
"( **",
94-
"** )",
95-
"[ []",
96-
"[code]",
97-
"[/code]",
98-
"[sub]",
99-
"[/sub]",
100-
"[sup]",
101-
"[/sup]",
102-
"[ins]",
103-
"[/ins]",
104-
"&lt;",
105-
"&gt;",
106-
"&amp;"
107-
};
108-
String[]toStr2 = {
109-
"<code>","</code>","<sub>","</sub>","<sup>","</sup>","<ins>",
110-
"</ins>",
111-
};
112-
StringreadmeMdJavadoc =
113-
"/**\n"
114-
+StringUtils.replaceEach(
115-
StringUtils.replaceEach(
116-
PATTERN.splitAsStream(readmeMdText)
117-
.map(
118-
line -> {
119-
StringfirstLine =
120-
line
121-
.replace(
122-
"\\.",
123-
" -")
124-
+"\\.";
125-
Stringstr =
126-
index[0]++
127-
==0
128-
?firstLine
129-
:line;
130-
returnline
131-
.isEmpty()
132-
?" *"
133-
:" * "
134-
+str;
135-
})
136-
.collect(
137-
Collectors.joining(
138-
"\n")),
139-
fromStr,
140-
toStr),
141-
fromStr2,
142-
toStr2)
143-
.replace("`**","` **")
144-
.replace(",**",", **")
145-
.replace("<ins>**","<ins> **")
146-
.replace("**</ins>","** </ins>")
147-
.replace("/*","{@literal /}*")
148-
.replace("*/","*{@literal /}")
149-
+"\n**/";
150-
StringpublicClass =
151-
solutionJavaText.contains("@SuppressWarnings")
152-
?"@SuppressWarnings"
153-
:"public class ";
154-
Files.write(path,getBytes(solutionJavaText,readmeMdJavadoc,publicClass));
49+
if (matcher.matches(entry.getFileName())) {
50+
FilejavaFile =entry.toFile();
51+
Pathpath =Paths.get(javaFile.getAbsolutePath());
52+
finalbyte[]solutionJava =Files.readAllBytes(path);
53+
StringsolutionJavaText =newString(solutionJava,UTF_8);
54+
int[]index = {0};
55+
String[]fromStr = {
56+
"(\"{{",
57+
"=\"{{",
58+
"\n- [",
59+
" board = [[",
60+
" grid = [[",
61+
" = [[",
62+
"**,",
63+
"**]",
64+
"(**",
65+
"**)",
66+
"[[]",
67+
"<code>",
68+
"</code>",
69+
"<sub>",
70+
"</sub>",
71+
"<sup>",
72+
"</sup>",
73+
"<ins>",
74+
"</ins>",
75+
"<",
76+
">",
77+
"&"
78+
};
79+
String[]fromStr2 = {
80+
"[code]","[/code]","[sub]","[/sub]","[sup]","[/sup]","[ins]",
81+
"[/ins]",
82+
};
83+
String[]toStr = {
84+
"(\"{ {",
85+
"=\"{ {",
86+
"\n-\\[",
87+
" board = [ [",
88+
" grid = [ [",
89+
" =\\[\\[",
90+
"** ,",
91+
"** ]",
92+
"( **",
93+
"** )",
94+
"[ []",
95+
"[code]",
96+
"[/code]",
97+
"[sub]",
98+
"[/sub]",
99+
"[sup]",
100+
"[/sup]",
101+
"[ins]",
102+
"[/ins]",
103+
"&lt;",
104+
"&gt;",
105+
"&amp;"
106+
};
107+
String[]toStr2 = {
108+
"<code>","</code>","<sub>","</sub>","<sup>","</sup>","<ins>",
109+
"</ins>",
110+
};
111+
StringreadmeMdJavadoc =
112+
"/**\n"
113+
+StringUtils.replaceEach(
114+
StringUtils.replaceEach(
115+
PATTERN.splitAsStream(readmeMdText)
116+
.map(
117+
line -> {
118+
String
119+
firstLine =
120+
line
121+
.replace(
122+
"\\.",
123+
" -")
124+
+"\\.";
125+
Stringstr =
126+
index[
127+
0]++
128+
==0
129+
?firstLine
130+
:line;
131+
returnline
132+
.isEmpty()
133+
?" *"
134+
:" * "
135+
+str;
136+
})
137+
.collect(
138+
Collectors.joining(
139+
"\n")),
140+
fromStr,
141+
toStr),
142+
fromStr2,
143+
toStr2)
144+
.replace("`**","` **")
145+
.replace(",**",", **")
146+
.replace("<ins>**","<ins> **")
147+
.replace("**</ins>","** </ins>")
148+
.replace("/*","{@literal /}*")
149+
.replace("*/","*{@literal /}")
150+
+"\n**/";
151+
StringpublicClass =
152+
solutionJavaText.contains("@SuppressWarnings")
153+
?"@SuppressWarnings"
154+
:solutionJavaText.contains("public class ")
155+
?"public class "
156+
:"class ";
157+
Files.write(path,getBytes(solutionJavaText,readmeMdJavadoc,publicClass));
158+
}
155159
}
156160
}
157161
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp