Search in sources :

Example 1 with DocletParser

use of org.eclipse.n4js.jsdoc.DocletParser in project n4js by eclipse.

the class LineTagTest method testLineTagDescr.

@SuppressWarnings("javadoc")
@Test
public void testLineTagDescr() {
    String in = "/** foo." + "\n * @stubLineTagTitle  tag description. " + "\n */";
    AbstractLineTagDefinition tag = new StubLineTagWithRegionDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    TagValue vDescription = lineTag.getValueByKey(StubLineTagWithRegionDefinition.DESCR);
    Text tabDescription = (Text) vDescription.getContents().get(0);
    String deString = tabDescription.getText();
    assertEquals("tag description. ", deString);
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) Text(org.eclipse.n4js.jsdoc.dom.Text) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) Test(org.junit.Test)

Example 2 with DocletParser

use of org.eclipse.n4js.jsdoc.DocletParser in project n4js by eclipse.

the class LineTagTest method testSimpleLineTag.

@SuppressWarnings("javadoc")
@Test
public void testSimpleLineTag() {
    String in = "/** foo.\n * @stubLineTagTitle \n */";
    AbstractLineTagDefinition tag = new StubLineTagWithRegionDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    assertEquals("stubLineTagTitle", lineTag.getTitle().getTitle());
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) Test(org.junit.Test)

Example 3 with DocletParser

use of org.eclipse.n4js.jsdoc.DocletParser in project n4js by eclipse.

the class LineTagTest method testLineTagWithRegionAndDescr.

@SuppressWarnings("javadoc")
@Test
public void testLineTagWithRegionAndDescr() {
    String in = "/** foo.\n * @stubLineTagTitle {@region value} tag description. \n */";
    AbstractLineTagDefinition tag = new StubLineTagWithRegionDefinition("stubLineTagTitle");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tag)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    TagValue region = lineTag.getValueByKey(StubLineTagWithRegionDefinition.REGION);
    Text strcturedText = (Text) region.getContents().get(0);
    assertEquals("@region value", strcturedText.getText());
    TagValue vDescription = lineTag.getValueByKey(StubLineTagWithRegionDefinition.DESCR);
    Text tabDescription = (Text) vDescription.getContents().get(0);
    String deString = tabDescription.getText();
    assertEquals("tag description. ", deString);
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) Text(org.eclipse.n4js.jsdoc.dom.Text) TagValue(org.eclipse.n4js.jsdoc.dom.TagValue) Test(org.junit.Test)

Example 4 with DocletParser

use of org.eclipse.n4js.jsdoc.DocletParser in project n4js by eclipse.

the class LineTagWithFullMemberReferenceTest method test_fullRef_simpleName.

@SuppressWarnings("javadoc")
@Test
public void test_fullRef_simpleName() {
    String in = "/** foo." + "\n * @testee n4/model/collections/DataSet.DataSet.each" + "\n */";
    AbstractLineTagDefinition tagDef = new LineTagWithFullMemberReference("testee");
    DocletParser docletParser = new DocletParser(new TagDictionary<>(Arrays.asList(tagDef)), new TagDictionary<AbstractInlineTagDefinition>());
    Doclet doclet = docletParser.parse(in);
    LineTag lineTag = doclet.getLineTags().get(0);
    EList<ContentNode> contents = lineTag.getValueByKey(LineTagWithFullElementReference.REF).getContents();
    FullMemberReference ref = (FullMemberReference) contents.get(0);
    assertEquals("n4/model/collections/DataSet", ref.getModuleName());
    assertEquals("DataSet", ref.getTypeName());
    assertEquals("each", ref.getMemberName());
}
Also used : LineTag(org.eclipse.n4js.jsdoc.dom.LineTag) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) DocletParser(org.eclipse.n4js.jsdoc.DocletParser) ContentNode(org.eclipse.n4js.jsdoc.dom.ContentNode) FullMemberReference(org.eclipse.n4js.jsdoc.dom.FullMemberReference) Test(org.junit.Test)

Example 5 with DocletParser

use of org.eclipse.n4js.jsdoc.DocletParser in project n4js by eclipse.

the class SimpleN4JSDocTest method assertSameSerializationForm.

/**
 * @param jsdocString
 *            jsDoc string
 */
private void assertSameSerializationForm(String jsdocString) {
    DocletParser docletParser = new N4JSDocletParser();
    Doclet doclet = docletParser.parse(jsdocString);
    String out = JSDocSerializer.toJSDocString(doclet);
    assertEquals(jsdocString, out);
}
Also used : N4JSDocletParser(org.eclipse.n4js.jsdoc.N4JSDocletParser) Doclet(org.eclipse.n4js.jsdoc.dom.Doclet) N4JSDocletParser(org.eclipse.n4js.jsdoc.N4JSDocletParser) DocletParser(org.eclipse.n4js.jsdoc.DocletParser)

Aggregations

DocletParser (org.eclipse.n4js.jsdoc.DocletParser)11 Doclet (org.eclipse.n4js.jsdoc.dom.Doclet)11 Test (org.junit.Test)9 LineTag (org.eclipse.n4js.jsdoc.dom.LineTag)6 Text (org.eclipse.n4js.jsdoc.dom.Text)6 N4JSDocletParser (org.eclipse.n4js.jsdoc.N4JSDocletParser)4 TagValue (org.eclipse.n4js.jsdoc.dom.TagValue)4 ContentNode (org.eclipse.n4js.jsdoc.dom.ContentNode)3 FullMemberReference (org.eclipse.n4js.jsdoc.dom.FullMemberReference)2 Composite (org.eclipse.n4js.jsdoc.dom.Composite)1 InlineTag (org.eclipse.n4js.jsdoc.dom.InlineTag)1