@@ -36,21 +36,10 @@ public static void main(String... args) throws Throwable {
36
36
final var aggregator = new AggregateSnippets (snippetsSrcRoot );
37
37
aggregator .computeContents ();
38
38
aggregator .saveContentsToFile (repoRoot .resolve ("SNIPPETS.md" ));
39
- if (args .length > 0 ) {
40
- aggregator .saveLineNumbersToCsv (Paths .get (args [0 ]));
41
- }
42
39
}
43
40
44
-
45
- public record CodeSnippetFileInfo (
46
- Path file ,
47
- int mainStartIndex , int mainEndIndex ,
48
- int clientStartIndex , int clientEndIndex
49
- ) { }
50
-
51
41
private StringBuilder sb ;
52
42
private final Path snippetsSrcRoot ;
53
- private Collection <CodeSnippetFileInfo > snippetFiles ;
54
43
55
44
public AggregateSnippets (Path snippetsSrcRoot ) {
56
45
this .snippetsSrcRoot = Objects .requireNonNull (snippetsSrcRoot );
@@ -62,11 +51,6 @@ private void checkComputed() {
62
51
}
63
52
}
64
53
65
- public Collection <CodeSnippetFileInfo > getLineNumbers () {
66
- checkComputed ();
67
- return snippetFiles ;
68
- }
69
-
70
54
public String getContents () {
71
55
checkComputed ();
72
56
return sb .toString ();
@@ -76,24 +60,7 @@ public void saveContentsToFile(Path destPath) throws IOException {
76
60
Files .writeString (destPath , getContents (), StandardOpenOption .CREATE );
77
61
}
78
62
79
- public void saveLineNumbersToCsv (Path destPath ) throws IOException {
80
- checkComputed ();
81
- try (var writer = Files .newBufferedWriter (destPath , StandardOpenOption .CREATE )) {
82
- writer .write ("File,MainStart,MainEnd,ClientStart,ClientEnd\n " );
83
- for (var metadata : snippetFiles ) {
84
- writer .write (
85
- metadata .file .getFileName () + "," +
86
- metadata .mainStartIndex + "," +
87
- metadata .mainEndIndex + "," +
88
- metadata .clientStartIndex + "," +
89
- metadata .clientEndIndex + "\n "
90
- );
91
- }
92
- }
93
- }
94
-
95
63
public void computeContents () throws IOException {
96
- snippetFiles = new ArrayList <>(256 );
97
64
final String classFileName = getClass ().getSimpleName () + ".java" ;
98
65
sb = new StringBuilder (1 << 17 )
99
66
.append ("# Vonage Java SDK Code Snippets\n " )
@@ -164,22 +131,9 @@ else if (level > 2 && path.getName().endsWith(".java")) {
164
131
.stripTrailing ().stripIndent ().replace ("\t " , " " );
165
132
166
133
sb .append ("\n ```java\n " ).append (nugget ).append ("\n ```\n " );
167
-
168
- boolean standalone = clientInitEndIndex < 12 ;
169
- snippetFiles .add (new CodeSnippetFileInfo (path .toPath (),
170
- lineNumberFromIndex (fileContent , startIndex ) + 1 ,
171
- lineNumberFromIndex (fileContent , endIndex ),
172
- standalone ? -1 : lineNumberFromIndex (fileContent , clientInitStartIndex ) + 1 ,
173
- standalone ? -1 : lineNumberFromIndex (fileContent , clientInitEndIndex )
174
- ));
175
134
}
176
135
}
177
136
178
- private static int lineNumberFromIndex (String content , int index ) {
179
- if (index < 0 ) return -1 ;
180
- return content .substring (0 , index ).split ("\n " ).length ;
181
- }
182
-
183
137
private static boolean isInitialize (File file ) {
184
138
return file .getName ().equals ("initialize" );
185
139
}
0 commit comments