use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testInlineCodeEnclosedTripleBackTicks.
@Test(description = "Test doc inline code with triple backtics.")
public void testInlineCodeEnclosedTripleBackTicks() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/doc_inline_triple.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable constant = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDocumentation> docNodes = constant.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 0);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string template:\n" + " ```string s = string `hello {{name}}`;```\n" + "\n" + " Example for an xml literal:\n" + " ```xml x = xml `<{{tagName}}>hello</{{tagName}}>`;```\n");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testDocTransformer.
@Test(description = "Test doc transformer.")
public void testDocTransformer() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/transformer.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangTransformer) packageNode.getTransformers().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, "\n" + " Transformer Foo Person -> Employee\n" + " ");
Assert.assertEquals(dNode.getAttributes().size(), 3);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "p");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " input struct Person source used for transformation\n ");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "e");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " output struct Employee struct which Person transformed to\n ");
Assert.assertEquals(dNode.getAttributes().get(2).documentationField.getValue(), "defaultAddress");
Assert.assertEquals(dNode.getAttributes().get(2).documentationText, " address which serves Eg: `POSTCODE 112`\n");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testDocAnnotation.
@Test(description = "Test doc annotation.")
public void testDocAnnotation() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/annotation.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangStruct) packageNode.getStructs().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for Test annotation\n");
Assert.assertEquals(dNode.getAttributes().size(), 3);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "a");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " annotation `field a` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "b");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " annotation `field b` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(2).documentationField.getValue(), "c");
Assert.assertEquals(dNode.getAttributes().get(2).documentationText, " annotation `field c` documentation");
docNodes = ((BLangAnnotation) packageNode.getAnnotations().get(0)).docAttachments;
dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testInlineCode.
@Test(description = "Test doc inline code.")
public void testInlineCode() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/doc_inline.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
BLangVariable connector = (BLangVariable) packageNode.getGlobalVariables().get(0);
List<BLangDocumentation> docNodes = connector.docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.getAttributes().size(), 0);
Assert.assertEquals(dNode.documentationText, "\n" + " Example of a string template:\n" + " ``string s = string `hello {{name}}`;``\n" + "\n" + " Example for an xml literal:\n" + " ``xml x = xml `<{{tagName}}>hello</{{tagName}}>`;``\n");
}
use of org.ballerinalang.launcher.util.CompileResult in project ballerina by ballerina-lang.
the class DocumentationTest method testDocStruct.
@Test(description = "Test doc struct.")
public void testDocStruct() {
CompileResult compileResult = BCompileUtil.compile("test-src/documentation/struct.bal");
Assert.assertEquals(0, compileResult.getWarnCount());
PackageNode packageNode = compileResult.getAST();
List<BLangDocumentation> docNodes = ((BLangStruct) packageNode.getStructs().get(0)).docAttachments;
BLangDocumentation dNode = docNodes.get(0);
Assert.assertNotNull(dNode);
Assert.assertEquals(dNode.documentationText, " Documentation for Test struct\n");
Assert.assertEquals(dNode.getAttributes().size(), 3);
Assert.assertEquals(dNode.getAttributes().get(0).documentationField.getValue(), "a");
Assert.assertEquals(dNode.getAttributes().get(0).documentationText, " struct `field a` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(1).documentationField.getValue(), "b");
Assert.assertEquals(dNode.getAttributes().get(1).documentationText, " struct `field b` documentation\n");
Assert.assertEquals(dNode.getAttributes().get(2).documentationField.getValue(), "c");
Assert.assertEquals(dNode.getAttributes().get(2).documentationText, " struct `field c` documentation");
}
Aggregations