use of org.eclipse.n4js.jsdoc.dom.LineTag 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);
}
use of org.eclipse.n4js.jsdoc.dom.LineTag 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());
}
use of org.eclipse.n4js.jsdoc.dom.LineTag 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);
}
use of org.eclipse.n4js.jsdoc.dom.LineTag in project n4js by eclipse.
the class DocletParser method parse.
/**
* @param commentString
* Input string that will be parsed. Multiline comment expected.
* @return Instance of Doclet (not null, but may have no contents).
*/
public Doclet parse(String commentString) {
JSDocCharScanner scanner = new JSDocCharScanner(commentString);
// parse main description
Doclet doclet = parseMainDescription(scanner);
TagTitleTokenizer tagTitleTokenizer = new TagTitleTokenizer();
JSDocToken token;
// TODO error handling
while (null != (token = tagTitleTokenizer.nextToken(scanner))) {
ITagDefinition tagDefinition = lineTagDictionary.getDefinition(token.token);
int lineTagEnd = scanner.findLineTagEnd();
scanner.fence(lineTagEnd);
if (tagDefinition != null) {
TagTitle tagTitle = createTagTitle(token, tagDefinition);
LineTag tag = (LineTag) tagDefinition.parse(tagTitle, scanner, descriptionParser);
tag.setRange(token.start, scanner.offset());
doclet.getLineTags().add(tag);
}
scanner.unfence();
scanner.setNextOffset(lineTagEnd);
}
doclet.setEnd(scanner.offset());
return doclet;
}
use of org.eclipse.n4js.jsdoc.dom.LineTag in project n4js by eclipse.
the class JSDoc2HoverSerializer method caseDoclet.
@Override
public Boolean caseDoclet(Doclet doclet) {
md2HtmlBuilder.resetMarkdownConverter();
appendContents(doclet.getContents());
// Reset md2HtmlBuilder to enforce all open blocks to closes, so that we have a defined status when
// handling the line tags.
md2HtmlBuilder.resetMarkdownConverter();
Map<ITagDefinition, List<LineTag>> groupedLineTags = new HashMap<>();
for (LineTag lineTag : doclet.getLineTags()) {
ITagDefinition tagDef = lineTag.getTagDefinition();
List<LineTag> group = groupedLineTags.get(tagDef);
if (group == null) {
group = new ArrayList<>(5);
groupedLineTags.put(tagDef, group);
}
group.add(lineTag);
}
if (!groupedLineTags.isEmpty()) {
md2HtmlBuilder.append("\n<dl>");
for (ITagDefinition tagDef : N4JSDocletParser.N4JS_LINE_TAGS) {
TagHandler tagHandler = LINETAG_HANDLERS.get(tagDef);
if (tagHandler == null) {
// default tag handler
tagHandler = TAG_SECTION;
}
if (tagHandler != null) {
List<LineTag> lineTags = groupedLineTags.get(tagDef);
handleLineTags(tagDef, tagHandler, lineTags);
// open/close dt/dd tags is handled appending tags directly
// reset state to isolate tag line from each other
md2HtmlBuilder.resetMarkdownConverter();
}
}
md2HtmlBuilder.append("\n</dl>");
}
return false;
}
Aggregations