3232 * @author Alexander Weigl
3333 * @version 1 (14.10.23)
3434 */
35- @ NullMarked
36- @ CommandLine .Command (name = "gendoc" ,
37- mixinStandardHelpOptions = true ,
38- version = "gendoc 1.0" ,
39- description = "Generates the documentation for key.api" )
40- public class ExtractMetaData implements Callable <Integer > {
35+
36+ public class ExtractMetaData implements Runnable {
4137 private final List <Metamodel .Endpoint > endpoints = new LinkedList <>();
4238 private final Map <Class <?>, Metamodel .Type > types = new HashMap <>();
4339 private final Map <String , HelpText > segDocumentation = new TreeMap <>();
@@ -48,18 +44,7 @@ public ExtractMetaData() {
4844 }
4945
5046 @ Override
51- public Integer call () throws IOException {
52- if (source != null ) {
53- ParserConfiguration config = new ParserConfiguration ();
54- config .setLanguageLevel (ParserConfiguration .LanguageLevel .JAVA_21 );
55- config .setAttributeComments (true );
56- config .setLexicalPreservationEnabled (false );
57- config .setStoreTokens (false );
58- config .setIgnoreAnnotationsWhenAttributingComments (true );
59- config .setDoNotAssignCommentsPrecedingEmptyLines (true );
60- sourceRoot = new SourceRoot (source , config );
61- }
62-
47+ public void run () {
6348 for (Method method : KeyApi .class .getMethods ()) {
6449 addServerEndpoint (method );
6550 }
@@ -284,7 +269,7 @@ private static HelpText printFieldDocumentation(FieldJavadoc javadoc) {
284269
285270 private void addClientEndpoint (Method method ) {
286271 var jsonSegment = method .getDeclaringClass ().getAnnotation (JsonSegment .class );
287- var segment = jsonSegment .value ();
272+ var segment = jsonSegment == null ? "" : jsonSegment .value ();
288273
289274 var req = method .getAnnotation (JsonRequest .class );
290275 var resp = method .getAnnotation (JsonNotification .class );
@@ -429,4 +414,8 @@ else if (type == CompletableFuture.class) {
429414
430415 return null ;
431416 }
417+
418+ public Metamodel .KeyApi getApi () {
419+ return keyApi ;
420+ }
432421}
0 commit comments