@@ -36,21 +36,10 @@ public static void main(String... args) throws Throwable {
3636 final var aggregator = new AggregateSnippets (snippetsSrcRoot );
3737 aggregator .computeContents ();
3838 aggregator .saveContentsToFile (repoRoot .resolve ("SNIPPETS.md" ));
39- if (args .length > 0 ) {
40- aggregator .saveLineNumbersToCsv (Paths .get (args [0 ]));
41- }
4239 }
4340
44-
45- public record CodeSnippetFileInfo (
46- Path file ,
47- int mainStartIndex , int mainEndIndex ,
48- int clientStartIndex , int clientEndIndex
49- ) { }
50-
5141 private StringBuilder sb ;
5242 private final Path snippetsSrcRoot ;
53- private Collection <CodeSnippetFileInfo > snippetFiles ;
5443
5544 public AggregateSnippets (Path snippetsSrcRoot ) {
5645 this .snippetsSrcRoot = Objects .requireNonNull (snippetsSrcRoot );
@@ -62,11 +51,6 @@ private void checkComputed() {
6251 }
6352 }
6453
65- public Collection <CodeSnippetFileInfo > getLineNumbers () {
66- checkComputed ();
67- return snippetFiles ;
68- }
69-
7054 public String getContents () {
7155 checkComputed ();
7256 return sb .toString ();
@@ -76,24 +60,7 @@ public void saveContentsToFile(Path destPath) throws IOException {
7660 Files .writeString (destPath , getContents (), StandardOpenOption .CREATE );
7761 }
7862
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-
9563 public void computeContents () throws IOException {
96- snippetFiles = new ArrayList <>(256 );
9764 final String classFileName = getClass ().getSimpleName () + ".java" ;
9865 sb = new StringBuilder (1 << 17 )
9966 .append ("# Vonage Java SDK Code Snippets\n " )
@@ -164,22 +131,9 @@ else if (level > 2 && path.getName().endsWith(".java")) {
164131 .stripTrailing ().stripIndent ().replace ("\t " , " " );
165132
166133 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- ));
175134 }
176135 }
177136
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-
183137 private static boolean isInitialize (File file ) {
184138 return file .getName ().equals ("initialize" );
185139 }
0 commit comments