1919@ SuppressWarnings ({"unchecked" , "rawtypes" })
2020public class ScraperDocgen {
2121 static Map <String , Object > docs = new HashMap <>();
22+ static Set <String > filter = new HashSet <>();
23+
2224 public static void main (String [] args ) {
2325 if (args .length < 2 ) throw new IllegalArgumentException ("First argument output file, following arguments folder paths to include" );
2426
@@ -36,11 +38,12 @@ public void visit(JavadocComment comment, Object arg) {
3638
3739 // empty javadoc node: return
3840 Optional <Node > nod = comment .getCommentedNode ();
39- if (nod .isEmpty ()) return ;
41+ if (nod .isEmpty ()) {
42+ return ;
43+ }
4044
4145 Node nodd = nod .get ();
4246 Map nodeDoc = (Map ) docs .getOrDefault (nname , new HashMap <>());
43- docs .put (nname , nodeDoc );
4447 List fields = (List ) nodeDoc .getOrDefault ("fields" , new LinkedList <>());
4548 nodeDoc .put ("fields" , fields );
4649
@@ -78,12 +81,23 @@ public void visit(JavadocComment comment, Object arg) {
7881
7982 // version
8083 Optional <AnnotationExpr > annotOpt = ((ClassOrInterfaceDeclaration ) nodd ).getAnnotationByName ("NodePlugin" );
81- if (annotOpt .isEmpty ()) return ;
84+ if (annotOpt .isEmpty ()) {
85+ filter .add (nname );
86+ return ;
87+ }
8288 AnnotationExpr annot = annotOpt .get ();
8389 String version ;
8490 if (annot instanceof SingleMemberAnnotationExpr ) {
8591 version = ((SingleMemberAnnotationExpr ) annot ).getMemberValue ().toString ();
8692 } else {
93+ Optional <MemberValuePair > deprecated = ((NormalAnnotationExpr ) annot ).getPairs ().stream ()
94+ .filter (p -> p .getName ().getId ().equals ("deprecated" ))
95+ .findFirst ();
96+ if (deprecated .isPresent () && deprecated .get ().getValue ().toString ().equalsIgnoreCase ("true" )) {
97+ filter .add (nname );
98+ return ;
99+ }
100+
87101 Optional <MemberValuePair > defaultVal = ((NormalAnnotationExpr ) annot ).getPairs ().stream ()
88102 .filter (p -> p .getName ().getId ().equals ("value" ))
89103 .findFirst ();
@@ -136,6 +150,8 @@ public void visit(JavadocComment comment, Object arg) {
136150 }
137151 fields .add (fieldDoc );
138152 }
153+
154+ docs .put (nname , nodeDoc );
139155 }
140156
141157 }.visit (JavaParser .parse (file ), null );
@@ -155,6 +171,8 @@ public void visit(JavadocComment comment, Object arg) {
155171 handleNode ).explore (projectDir );
156172 }
157173
174+ filter .forEach (v -> docs .remove (v ));
175+
158176 HtmlGenerator .main (output );
159177 }
160178
0 commit comments