private void render(EnumModel model, PrintWriter html) { html.append("[[").append(model.getType().getSimpleName()).append("]]\n"); html.append("== ").append(model.getType().getSimpleName()).append("\n"); html.append("\n"); Doc doc = model.getDoc(); if (doc != null) { html.append("++++\n"); Token.toHtml(doc.getTokens(), "", Tag::getName, "\n", html); html.append("++++\n"); html.append("'''\n"); } html.append("\n"); html.append("[cols=\">25%,75%\"]\n"); html.append("[frame=\"topbot\"]\n"); html.append("|===\n"); html.append("^|Name | Description\n"); model.getValues().forEach(value -> { html.append("|[[").append(value.getIdentifier()).append("]]`").append(value.getIdentifier()).append("`"); html.append("|"); if (value.getDoc() != null) { html.append("+++\n"); html.append(Token.toHtml(value.getDoc().getTokens(), "", Tag::getName, "\n").trim()).append("\n"); html.append("+++\n"); } else { html.append("-\n"); } }); html.append("|===\n"); } }
@Test public void testEnum() throws Exception { EnumModel model = new GeneratorHelper().generateEnum(ValidEnum.class); assertEquals(Arrays.asList("RED", "GREEN", "BLUE"), model.getValues().stream(). map(EnumValueInfo::getIdentifier). collect(Collectors.toList())); assertEquals(Arrays.asList("RED doc", "GREEN doc", "BLUE doc"), model.getValues().stream(). map(e -> e.getDoc().toString()). collect(Collectors.toList())); assertEquals("enum", model.getKind()); assertEquals("ValidEnum doc", model.getDoc().toString()); assertEquals(ValidEnum.class.getName(), model.getFqn()); assertEquals("dummy", model.getModule().getName()); assertTrue(model.getType().isGen()); }
@Test public void testNoDocEnum() throws Exception { EnumModel model = new GeneratorHelper().generateEnum(NoDocEnum.class); assertNull(model.getDoc()); assertNull(model.getDeprecatedDesc()); }