|
49 | 49 | * @author Markus Michael Geipel
|
50 | 50 | */
|
51 | 51 | public final class HelpPrinter {
|
| 52 | + |
52 | 53 | private static final String PATH_TO_EXAMPLES = "../metafacture-documentation/linksAndExamples.tsv";
|
53 | 54 | private static final Map<String, String[]> EXAMPLES_MAP = new HashMap<>();
|
54 |
| - private static final int COLUMN_TO_PG_EXAMPLE = 3; |
55 |
| - private static final int MAX_COLUMNS_OF_EXAMPLE = COLUMN_TO_PG_EXAMPLE; |
56 |
| - private static final int MIN_COLUMNS_OF_EXAMPLE = 2; |
57 | 55 |
|
58 | 56 | private HelpPrinter() {
|
59 | 57 | // no instances
|
@@ -127,17 +125,10 @@ private static <T> void describe(final String name, final ObjectFactory<T> facto
|
127 | 125 | printSignature(out, moduleClass);
|
128 | 126 |
|
129 | 127 | final String[] examplesEntry = EXAMPLES_MAP.get(name);
|
130 |
| - if (!EXAMPLES_MAP.isEmpty() && (examplesEntry == null || examplesEntry.length < MIN_COLUMNS_OF_EXAMPLE || |
131 |
| - examplesEntry.length > MAX_COLUMNS_OF_EXAMPLE)) { |
132 |
| - throw new MetafactureException( |
133 |
| - "Failed to load build infos: tsv with links hasn't at least " + MIN_COLUMNS_OF_EXAMPLE + " " + |
134 |
| - "or exceeds the number of allowed columns (i.e. " + MAX_COLUMNS_OF_EXAMPLE + ")" + |
135 |
| - " for the entry '" + name + "'"); |
136 |
| - } |
137 |
| - if (examplesEntry != null && examplesEntry.length == COLUMN_TO_PG_EXAMPLE) { |
138 |
| - out.println("- [example in Playground]" + "(" + examplesEntry[COLUMN_TO_PG_EXAMPLE - 1] + ")"); |
| 128 | + if (examplesEntry != null && examplesEntry.length > 2) { |
| 129 | + out.println("- [example in Playground]" + "(" + examplesEntry[2] + ")"); |
139 | 130 | }
|
140 |
| - if (examplesEntry != null) { |
| 131 | + if (examplesEntry != null && examplesEntry.length > 1) { |
141 | 132 | out.println("- java class:\t[" + moduleClass.getCanonicalName() + "](" + examplesEntry[1] + ")");
|
142 | 133 | }
|
143 | 134 | else {
|
@@ -213,6 +204,10 @@ private static void loadExamples() throws IOException {
|
213 | 204 | while ((line = bufferedReader.readLine()) != null) {
|
214 | 205 | final String[] tsv = line.split("\t");
|
215 | 206 | EXAMPLES_MAP.put(tsv[0], tsv);
|
| 207 | + |
| 208 | + if (tsv.length < 2) { |
| 209 | + System.err.println("Invalid command info: " + line); |
| 210 | + } |
216 | 211 | }
|
217 | 212 | }
|
218 | 213 | }
|
|
0 commit comments