@@ -54,6 +54,10 @@ public final class HelpPrinter {
54
54
55
55
private static final Map <String , String []> EXAMPLES_MAP = new HashMap <>();
56
56
57
+ private static final String INDENTATION = " " ;
58
+
59
+ private static StringBuilder htmlTable = new StringBuilder ();
60
+
57
61
private HelpPrinter () {
58
62
// no instances
59
63
}
@@ -91,9 +95,12 @@ public static void print(final ObjectFactory<?> factory,
91
95
final List <String > keyWords = new ArrayList <>(factory .keySet ());
92
96
Collections .sort (keyWords );
93
97
loadExamples ();
98
+ htmlTable .append (INDENTATION +INDENTATION +"<tbody>\n " );
94
99
for (final String name : keyWords ) {
95
100
describe (name , factory , out );
96
101
}
102
+ htmlTable .append (INDENTATION +INDENTATION +"</tbody>\n " );
103
+ out .println (htmlTable );
97
104
}
98
105
99
106
private static String getVersionInfo () {
@@ -109,33 +116,53 @@ private static <T> void describe(final String name, final ObjectFactory<T> facto
109
116
final ConfigurableClass <? extends T > configurableClass = factory .get (name );
110
117
final Class <? extends T > moduleClass = configurableClass .getPlainClass ();
111
118
final Description desc = moduleClass .getAnnotation (Description .class );
112
-
119
+ String indentation = INDENTATION + INDENTATION + INDENTATION ;
113
120
out .println (name );
121
+ htmlTable .append (indentation +"<tr>\n " );
122
+ indentation =indentation +INDENTATION ;
123
+ htmlTable .append (indentation +"<td>" +name +"</td>\n " );
124
+
114
125
name .chars ().forEach (c -> out .print ("-" ));
115
126
out .println ();
116
-
127
+ htmlTable . append ( indentation + "<td>" );
117
128
if (desc != null ) {
118
129
out .println ("- description:\t " + desc .value ());
130
+ htmlTable .append (desc .value ());
119
131
}
120
132
final Collection <String > arguments = getAvailableArguments (moduleClass );
121
133
if (!arguments .isEmpty ()) {
122
134
out .println ("- arguments:\t " + arguments );
135
+ htmlTable .append ("\n Arguments: " +arguments );
123
136
}
137
+ htmlTable .append ("</td>\n " );
124
138
139
+ htmlTable .append (indentation );
125
140
printAttributes (out , configurableClass , configurableClass .getSetters ());
141
+ htmlTable .append (indentation );
126
142
printSignature (out , moduleClass );
127
143
128
144
final String [] examplesEntry = EXAMPLES_MAP .get (name );
145
+ htmlTable .append (indentation +"<td>" );
129
146
if (examplesEntry != null && examplesEntry .length > 2 ) {
130
147
out .println ("- [example in Playground]" + "(" + examplesEntry [2 ] + ")" );
148
+ htmlTable .append ("<a href=\" " +examplesEntry [2 ]+"\" >example in Playground</a>" );
131
149
}
132
- if (examplesEntry != null && examplesEntry .length > 1 ) {
150
+ htmlTable .append ("</td>\n " );
151
+
152
+ htmlTable .append (indentation +"<td>" );
153
+ if (examplesEntry != null && examplesEntry .length > 1 ) {
133
154
out .println ("- java class:\t [" + moduleClass .getCanonicalName () + "](" + examplesEntry [1 ] + ")" );
134
- }
155
+ htmlTable .append ("<a href=\" " +examplesEntry [1 ]+"\" >" + moduleClass .getCanonicalName ()+"</a>" );
156
+ }
135
157
else {
136
158
out .println ("- java class:\t " + moduleClass .getCanonicalName ());
137
- }
138
- out .println ();
159
+ htmlTable .append (moduleClass .getCanonicalName ());
160
+
161
+ }
162
+ htmlTable .append ("</td>\n " );
163
+
164
+ out .println ();
165
+ htmlTable .append (INDENTATION +INDENTATION +INDENTATION +"</tr>\n " );
139
166
}
140
167
141
168
private static <T > void printSignature (final PrintStream out , final Class <? extends T > moduleClass ) {
@@ -150,10 +177,13 @@ private static <T> void printSignature(final PrintStream out, final Class<? exte
150
177
outString = outClass .value ().getSimpleName ();
151
178
}
152
179
out .println ("- signature:\t " + inString + " -> " + outString );
180
+ htmlTable .append ("<td>" +inString +"</td>\n " );
181
+ htmlTable .append ("<td>" +outString +"</td>\n " );
153
182
}
154
183
155
184
private static <T > void printAttributes (final PrintStream out , final ConfigurableClass <? extends T > configurableClass , final Map <String , Method > attributes ) {
156
- if (!attributes .isEmpty ()) {
185
+ String options ="" ;
186
+ if (!attributes .isEmpty ()) {
157
187
out .print ("- options:\t " );
158
188
final StringBuilder builder = new StringBuilder ();
159
189
for (final Entry <String , Method > entry : attributes .entrySet ()) {
@@ -178,8 +208,11 @@ private static <T> void printAttributes(final PrintStream out, final Configurabl
178
208
}
179
209
180
210
}
181
- out .println (builder .substring (0 , builder .length () - 2 ));
211
+ options = builder .substring (0 , builder .length () - 2 );
212
+ out .println (options );
182
213
}
214
+ htmlTable .append ("<td>" +options +"</td>\n " );
215
+
183
216
}
184
217
185
218
@ SuppressWarnings ("unchecked" )
0 commit comments