Search in sources :

Example 1 with DescriptionListEntry

use of org.asciidoctor.ast.DescriptionListEntry in project drools by kiegroup.

the class ADocFEELExamplesTest method processBlock.

private void processBlock(StructuralNode block) {
    List<StructuralNode> blocks = block.getBlocks();
    for (int i = 0; i < blocks.size(); i++) {
        final StructuralNode currentBlock = blocks.get(i);
        if (currentBlock instanceof StructuralNode) {
            if (currentBlock instanceof DescriptionList) {
                DescriptionList descriptionList = (DescriptionList) currentBlock;
                for (DescriptionListEntry dle : descriptionList.getItems()) {
                    ListItem description = dle.getDescription();
                    processBlock(description);
                }
            } else if ("listing".equals(currentBlock.getContext())) {
                Block b = (Block) currentBlock;
                List<String> lines = b.getLines();
                LOG.trace("{}", lines);
                LOG.trace("{}", b.getAttributes());
                if (b.getAttribute("language", "unknown").equals("FEEL")) {
                    for (String line : lines) {
                        LOG.info("checking DOC {}", line);
                        Object FEELResult = feel.evaluate(line);
                        Assert.assertThat(line, FEELResult, Matchers.is(true));
                    }
                } else {
                    LOG.trace("This block is not FEEL true predicate snippets: {}", b);
                }
            } else {
                processBlock(currentBlock);
            }
        }
    }
}
Also used : StructuralNode(org.asciidoctor.ast.StructuralNode) DescriptionListEntry(org.asciidoctor.ast.DescriptionListEntry) DescriptionList(org.asciidoctor.ast.DescriptionList) Block(org.asciidoctor.ast.Block) DescriptionList(org.asciidoctor.ast.DescriptionList) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.asciidoctor.ast.ListItem)

Example 2 with DescriptionListEntry

use of org.asciidoctor.ast.DescriptionListEntry in project jqa-core-framework by buschmais.

the class DocumentParser method parse.

private void parse(Collection<?> blocks, Map<String, StructuralNode> conceptBlocks, Map<String, StructuralNode> constraintBlocks, Map<String, StructuralNode> groupBlocks) {
    if (blocks != null) {
        for (Object element : blocks) {
            if (element instanceof StructuralNode && !(element instanceof DescriptionListEntry)) {
                StructuralNode block = (StructuralNode) element;
                String role = block.getRole();
                if (role != null) {
                    String id = (String) block.getAttribute(ID);
                    if (ROLE_CONCEPT.equalsIgnoreCase(role)) {
                        conceptBlocks.put(id, block);
                    } else if (ROLE_CONSTRAINT.equalsIgnoreCase(role)) {
                        constraintBlocks.put(id, block);
                    } else if (ROLE_GROUP.equalsIgnoreCase(role)) {
                        groupBlocks.put(id, block);
                    }
                }
                parse(block.getBlocks(), conceptBlocks, constraintBlocks, groupBlocks);
            } else if (element instanceof Collection<?>) {
                parse((Collection<?>) element);
            }
        }
    }
}
Also used : StructuralNode(org.asciidoctor.ast.StructuralNode) DescriptionListEntry(org.asciidoctor.ast.DescriptionListEntry) Collection(java.util.Collection) ToString(lombok.ToString)

Aggregations

DescriptionListEntry (org.asciidoctor.ast.DescriptionListEntry)2 StructuralNode (org.asciidoctor.ast.StructuralNode)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 ToString (lombok.ToString)1 Block (org.asciidoctor.ast.Block)1 DescriptionList (org.asciidoctor.ast.DescriptionList)1 ListItem (org.asciidoctor.ast.ListItem)1