@Test public void testConfigOptionExclusion() { final String expectedTable = "<table class=\"table table-bordered\">\n" + " <thead>\n" + " <tr>\n" + " <th class=\"text-left\" style=\"width: 20%\">Key</th>\n" + " <th class=\"text-left\" style=\"width: 15%\">Default</th>\n" + " <th class=\"text-left\" style=\"width: 65%\">Description</th>\n" + " </tr>\n" + " </thead>\n" + " <tbody>\n" + " <tr>\n" + " <td><h5>first.option.a</h5></td>\n" + " <td style=\"word-wrap: break-word;\">2</td>\n" + " <td>This is example description for the first option.</td>\n" + " </tr>\n" + " </tbody>\n" + "</table>\n"; final String htmlTable = ConfigOptionsDocGenerator.generateTablesForClass(TestConfigGroupWithExclusion.class).get(0).f1; assertEquals(expectedTable, htmlTable); }
@VisibleForTesting static List<Tuple2<ConfigGroup, String>> generateTablesForClass(Class<?> optionsClass) { ConfigGroups configGroups = optionsClass.getAnnotation(ConfigGroups.class); List<OptionWithMetaInfo> allOptions = extractConfigOptions(optionsClass); List<Tuple2<ConfigGroup, String>> tables; if (configGroups != null) { tables = new ArrayList<>(configGroups.groups().length + 1); Tree tree = new Tree(configGroups.groups(), allOptions); for (ConfigGroup group : configGroups.groups()) { List<OptionWithMetaInfo> configOptions = tree.findConfigOptions(group); sortOptions(configOptions); tables.add(Tuple2.of(group, toHtmlTable(configOptions))); } List<OptionWithMetaInfo> configOptions = tree.getDefaultOptions(); sortOptions(configOptions); tables.add(Tuple2.of(null, toHtmlTable(configOptions))); } else { sortOptions(allOptions); tables = Collections.singletonList(Tuple2.of(null, toHtmlTable(allOptions))); } return tables; }
ConfigOptionsDocGenerator { @VisibleForTesting static List<Tuple2<ConfigGroup, String>> generateTablesForClass(Class<?> optionsClass) { ConfigGroups configGroups = optionsClass.getAnnotation(ConfigGroups.class); List<OptionWithMetaInfo> allOptions = extractConfigOptions(optionsClass); List<Tuple2<ConfigGroup, String>> tables; if (configGroups != null) { tables = new ArrayList<>(configGroups.groups().length + 1); Tree tree = new Tree(configGroups.groups(), allOptions); for (ConfigGroup group : configGroups.groups()) { List<OptionWithMetaInfo> configOptions = tree.findConfigOptions(group); sortOptions(configOptions); tables.add(Tuple2.of(group, toHtmlTable(configOptions))); } List<OptionWithMetaInfo> configOptions = tree.getDefaultOptions(); sortOptions(configOptions); tables.add(Tuple2.of(null, toHtmlTable(configOptions))); } else { sortOptions(allOptions); tables = Collections.singletonList(Tuple2.of(null, toHtmlTable(allOptions))); } return tables; } }
ConfigOptionsDocGenerator { @VisibleForTesting static List<Tuple2<ConfigGroup, String>> generateTablesForClass(Class<?> optionsClass) { ConfigGroups configGroups = optionsClass.getAnnotation(ConfigGroups.class); List<OptionWithMetaInfo> allOptions = extractConfigOptions(optionsClass); List<Tuple2<ConfigGroup, String>> tables; if (configGroups != null) { tables = new ArrayList<>(configGroups.groups().length + 1); Tree tree = new Tree(configGroups.groups(), allOptions); for (ConfigGroup group : configGroups.groups()) { List<OptionWithMetaInfo> configOptions = tree.findConfigOptions(group); sortOptions(configOptions); tables.add(Tuple2.of(group, toHtmlTable(configOptions))); } List<OptionWithMetaInfo> configOptions = tree.getDefaultOptions(); sortOptions(configOptions); tables.add(Tuple2.of(null, toHtmlTable(configOptions))); } else { sortOptions(allOptions); tables = Collections.singletonList(Tuple2.of(null, toHtmlTable(allOptions))); } return tables; } private  ConfigOptionsDocGenerator(); }
ConfigOptionsDocGenerator { @VisibleForTesting static List<Tuple2<ConfigGroup, String>> generateTablesForClass(Class<?> optionsClass) { ConfigGroups configGroups = optionsClass.getAnnotation(ConfigGroups.class); List<OptionWithMetaInfo> allOptions = extractConfigOptions(optionsClass); List<Tuple2<ConfigGroup, String>> tables; if (configGroups != null) { tables = new ArrayList<>(configGroups.groups().length + 1); Tree tree = new Tree(configGroups.groups(), allOptions); for (ConfigGroup group : configGroups.groups()) { List<OptionWithMetaInfo> configOptions = tree.findConfigOptions(group); sortOptions(configOptions); tables.add(Tuple2.of(group, toHtmlTable(configOptions))); } List<OptionWithMetaInfo> configOptions = tree.getDefaultOptions(); sortOptions(configOptions); tables.add(Tuple2.of(null, toHtmlTable(configOptions))); } else { sortOptions(allOptions); tables = Collections.singletonList(Tuple2.of(null, toHtmlTable(allOptions))); } return tables; } private  ConfigOptionsDocGenerator(); static void main(String[] args); }
ConfigOptionsDocGenerator { @VisibleForTesting static List<Tuple2<ConfigGroup, String>> generateTablesForClass(Class<?> optionsClass) { ConfigGroups configGroups = optionsClass.getAnnotation(ConfigGroups.class); List<OptionWithMetaInfo> allOptions = extractConfigOptions(optionsClass); List<Tuple2<ConfigGroup, String>> tables; if (configGroups != null) { tables = new ArrayList<>(configGroups.groups().length + 1); Tree tree = new Tree(configGroups.groups(), allOptions); for (ConfigGroup group : configGroups.groups()) { List<OptionWithMetaInfo> configOptions = tree.findConfigOptions(group); sortOptions(configOptions); tables.add(Tuple2.of(group, toHtmlTable(configOptions))); } List<OptionWithMetaInfo> configOptions = tree.getDefaultOptions(); sortOptions(configOptions); tables.add(Tuple2.of(null, toHtmlTable(configOptions))); } else { sortOptions(allOptions); tables = Collections.singletonList(Tuple2.of(null, toHtmlTable(allOptions))); } return tables; } private  ConfigOptionsDocGenerator(); static void main(String[] args);  }