From 94276d2f396845ace86443793e2a2fc5418f8494 Mon Sep 17 00:00:00 2001 From: Katarzyna Marek Date: Thu, 18 Apr 2024 14:46:09 +0200 Subject: [PATCH] extract common scala docstring printers part --- .../meta/internal/metals/Docstrings.scala | 6 +- .../meta/internal/metals/JavadocIndexer.scala | 2 +- .../internal/metals/ScaladocIndexer.scala | 21 +-- .../metals/docstrings/MarkdownGenerator.scala | 177 ------------------ .../docstrings/PlaintextGenerator.scala | 98 ---------- .../printers/MarkdownGenerator.scala | 86 +++++++++ .../printers/PlaintextGenerator.scala | 43 +++++ .../docstrings/printers/ScalaDocPrinter.scala | 145 ++++++++++++++ .../tests/hover/HoverPlaintextSuite.scala | 7 + .../src/test/scala/tests/JavadocSuite.scala | 2 +- 10 files changed, 294 insertions(+), 293 deletions(-) delete mode 100644 mtags/src/main/scala/scala/meta/internal/metals/docstrings/MarkdownGenerator.scala delete mode 100644 mtags/src/main/scala/scala/meta/internal/metals/docstrings/PlaintextGenerator.scala create mode 100644 mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/MarkdownGenerator.scala create mode 100644 mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/PlaintextGenerator.scala create mode 100644 mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/ScalaDocPrinter.scala diff --git a/mtags/src/main/scala/scala/meta/internal/metals/Docstrings.scala b/mtags/src/main/scala/scala/meta/internal/metals/Docstrings.scala index 0d09c96e32b..7390f5d5913 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/Docstrings.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/Docstrings.scala @@ -21,10 +21,10 @@ import scala.meta.internal.semanticdb.SymbolInformation import scala.meta.internal.semanticdb.SymbolOccurrence import scala.meta.io.AbsolutePath import scala.meta.pc.ContentType -import scala.meta.pc.ParentSymbols -import scala.meta.pc.SymbolDocumentation import scala.meta.pc.ContentType.MARKDOWN import scala.meta.pc.ContentType.PLAINTEXT +import scala.meta.pc.ParentSymbols +import scala.meta.pc.SymbolDocumentation /** * Implementation of the `documentation(symbol: String): Option[SymbolDocumentation]` method in `SymbolSearch`. @@ -183,7 +183,7 @@ class Markdown(val text: String) extends AnyVal with Content class Plain(val text: String) extends AnyVal with Content object Content { - def from(text: String, contentType: ContentType) = + def from(text: String, contentType: ContentType): AnyVal with Content = contentType match { case MARKDOWN => new Markdown(text) case PLAINTEXT => new Plain(text) diff --git a/mtags/src/main/scala/scala/meta/internal/metals/JavadocIndexer.scala b/mtags/src/main/scala/scala/meta/internal/metals/JavadocIndexer.scala index adef897a473..e15bca9f32d 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/JavadocIndexer.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/JavadocIndexer.scala @@ -6,7 +6,7 @@ import scala.util.control.NonFatal import scala.meta.inputs.Input import scala.meta.inputs.Position -import scala.meta.internal.docstrings.MarkdownGenerator +import scala.meta.internal.docstrings.printers.MarkdownGenerator import scala.meta.internal.jdk.CollectionConverters._ import scala.meta.internal.mtags.JavaMtags import scala.meta.internal.semanticdb.Scala.Descriptor diff --git a/mtags/src/main/scala/scala/meta/internal/metals/ScaladocIndexer.scala b/mtags/src/main/scala/scala/meta/internal/metals/ScaladocIndexer.scala index 6000837aa3a..0850624e9ca 100644 --- a/mtags/src/main/scala/scala/meta/internal/metals/ScaladocIndexer.scala +++ b/mtags/src/main/scala/scala/meta/internal/metals/ScaladocIndexer.scala @@ -31,6 +31,12 @@ class ScaladocIndexer( sinfo: SymbolInformation, owner: String ): Unit = { + val printer = + contentType match { + case MARKDOWN => printers.MarkdownGenerator + case PLAINTEXT => printers.PlaintextGenerator + } + val docstring = currentTree.origin match { case ScalametaCompat.ParsedOrigin(start, _) => val leadingDocstring = @@ -47,23 +53,12 @@ class ScaladocIndexer( // Register `@define` macros to use for expanding in later docstrings. defines ++= ScaladocParser.extractDefines(docstring) val comment = ScaladocParser.parseComment(docstring, defines) - val docstringContent = - contentType match { - case MARKDOWN => - MarkdownGenerator.toMarkdown(comment, docstring) - case PLAINTEXT => - PlaintextGenerator.toPlaintext(comment, docstring) - } + val docstringContent = printer.toText(comment, docstring) def param(name: String, default: String): SymbolDocumentation = { val paramDoc = comment.valueParams .get(name) .orElse(comment.typeParams.get(name)) - .map { body => - contentType match { - case MARKDOWN => MarkdownGenerator.toMarkdown(body) - case PLAINTEXT => PlaintextGenerator.toPlaintext(body) - } - } + .map(printer.toText) .getOrElse("") MetalsSymbolDocumentation( Symbols.Global(owner, Descriptor.Parameter(name)), diff --git a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/MarkdownGenerator.scala b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/MarkdownGenerator.scala deleted file mode 100644 index 0d3ba4cbdc1..00000000000 --- a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/MarkdownGenerator.scala +++ /dev/null @@ -1,177 +0,0 @@ -package scala.meta.internal.docstrings - -import scala.collection.Seq -import scala.util.matching.Regex - -import scala.meta._ -import scala.meta.dialects.Scala213 - -/** - * Generates markdown from the docstring - * The markdown can be returned to the IDE and rendered to the user - */ -object MarkdownGenerator { - - /** - * Generates markdown from code - * - * @param code the input code - * @return a sequence of markdown strings - one per docstring comment in the code - */ - def toMarkdown(code: String): Seq[String] = - Scala213(code).tokenize.get.collect { - case c: Token.Comment if c.syntax.startsWith("/**") => - fromDocstring(c.syntax, Map.empty) - } - - def fromDocstring( - docstring: String, - defines: collection.Map[String, String] - ): String = { - toMarkdown(ScaladocParser.parseComment(docstring, defines), docstring) - } - - def toMarkdown(b: Body): String = { - Option(b) - .map(body => blocksToMarkdown(body.blocks)) - .mkString - } - - def toMarkdown(c: Comment, docstring: String): String = { - - def sortInSection( - section: String, - items: Seq[(String, Body)] - ): Seq[(String, Body)] = { - items.sortBy { case (key, _) => - val reg = new Regex(s"@$section\\s+$key") - reg.findFirstMatchIn(docstring).map(_.start).getOrElse(Int.MaxValue) - } - } - - Seq( - toMarkdown(c.body), - if (c.constructor.nonEmpty) - "\n" + c.constructor - .map(body => "**Constructor:** " + blocksToMarkdown(body.blocks)) - .mkString("\n") - else "", - if (c.deprecated.nonEmpty) - "\n" + c.deprecated - .map(body => "**Deprecated:** " ++ blocksToMarkdown(body.blocks)) - .mkString("\n") - else "", - if (c.example.nonEmpty) - "\n**Examples**\n" + c.example - .map(body => blocksToMarkdown(body.blocks)) - .mkString("\n", "\n", "") - else "", - if (c.note.nonEmpty) - "\n**Notes**\n" + - c.note - .map(body => "- " + blocksToMarkdown(body.blocks)) - .mkString("\n") - else "", - if (c.typeParams.nonEmpty) - "\n**Type Parameters**\n" + - sortInSection("tparam", c.typeParams.toSeq) - .map(tuple => - s"- `${tuple._1}`: " + blocksToMarkdown(tuple._2.blocks) - ) - .mkString - else - "", - if (c.valueParams.nonEmpty) - "\n**Parameters**\n" + sortInSection("param", c.valueParams.toSeq) - .map(tuple => - s"- `${tuple._1}`: " + blocksToMarkdown(tuple._2.blocks) - ) - .mkString - else - "", - if (c.result.nonEmpty) - "\n" + c.result - .map(body => "**Returns:** " ++ blocksToMarkdown(body.blocks)) - .mkString("\n") - else "", - if (c.throws.nonEmpty) - "\n**Throws**\n" + sortInSection("throws", c.throws.toSeq) - .map(tuple => - s"- `${tuple._1}`: " + tuple._2.summary - .map(inlineToMarkdown) - .getOrElse("") - ) - .mkString("", "\n", "\n") - else "", - if (c.see.nonEmpty) - "\n**See**\n" + c.see - .map { body => s"- ${blocksToMarkdown(body.blocks).trim}" } - .mkString("", "\n", "\n") - else "" - ).reduce(_ + _).trim - } - - private def blocksToMarkdown(blocks: Seq[Block], listLevel: Int = 0): String = - blocks.map(block => blockToMarkdown(block, listLevel)).mkString("\n") - - private def listBlockIndent(b: Block, bullet: Char, listLevel: Int): String = - b match { - case _: OrderedList | _: UnorderedList => - "" - case _ => - s"""${"\t" * listLevel}${bullet} """ - } - - private def listBlocksIndent( - blocks: Seq[Block], - bullet: Char, - listLevel: Int - ): String = - blocks - .map((b: Block) => - s"${this.listBlockIndent(b, bullet, listLevel)}${this - .blockToMarkdown(b, listLevel + 1)}" - ) - .mkString - - private def blockToMarkdown(block: Block, listLevel: Int): String = - block match { - case Title(text, level) => - s"""${"#" * level} ${inlineToMarkdown(text)}""" - case UnorderedList(blocks) => - this.listBlocksIndent(blocks, '-', listLevel) - case OrderedList(blocks, _) => - this.listBlocksIndent(blocks, '*', listLevel) - case Paragraph(text) => - s"${inlineToMarkdown(text)}\n" - case Code(data) => - s"```\n$data\n```" - case HorizontalRule() => - "---" - case _ => - "" - } - - private def inlineToMarkdown(i: Inline): String = { - i match { - case Chain(items) => - items.map(inlineToMarkdown).mkString - case Summary(text) => - inlineToMarkdown(text) - case Monospace(text) => - s"`${inlineToMarkdown(text)}`" - case Text(text) => - text - case HtmlTag(data) => - data - case Italic(text) => - s"*${inlineToMarkdown(text)}*" - case Bold(text) => - s"**${inlineToMarkdown(text)}**" - case Link(target, title) => - s"[${inlineToMarkdown(title)}]($target)" - case _ => - "" - } - } -} diff --git a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/PlaintextGenerator.scala b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/PlaintextGenerator.scala deleted file mode 100644 index 678b8fcef37..00000000000 --- a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/PlaintextGenerator.scala +++ /dev/null @@ -1,98 +0,0 @@ -package scala.meta.internal.docstrings - -import scala.collection.Seq -import scala.util.matching.Regex - -object PlaintextGenerator { - def toPlaintext(b: Body): String = - Option(b).map(body => printBlocks(body.blocks)).mkString("\n") - - def toPlaintext(c: Comment, docstring: String): String = { - - def sortInSection( - section: String, - items: Seq[(String, Body)] - ): Seq[(String, Body)] = { - items.sortBy { case (key, _) => - val reg = new Regex(s"@$section\\s+$key") - reg.findFirstMatchIn(docstring).map(_.start).getOrElse(Int.MaxValue) - } - } - - def printSection(name: String, optBody: Seq[Body]) = - if (optBody.nonEmpty) - optBody - .map(body => s"@$name ${printBlocks(body.blocks)}") - .mkString("\n", "\n", "") - else "" - - def printSortedSection(name: String, section: Seq[(String, Body)]) = - if (section.nonEmpty) - sortInSection(name, section) - .map(tuple => s"@$name ${tuple._1}: " + printBlocks(tuple._2.blocks)) - .mkString("\n", "\n", "") - else "" - - Seq( - toPlaintext(c.body), - printSection("constructor", c.constructor.toSeq), - printSection("deprecated", c.deprecated.toSeq), - printSection("example", c.example), - printSection("notes", c.note), - printSortedSection("tparam", c.typeParams.toSeq), - printSortedSection("param", c.valueParams.toSeq), - printSection("returns", c.result.toSeq), - printSortedSection("throws", c.throws.toSeq), - printSection("see", c.see) - ).reduce(_ + _).trim - } - - private def printBlocks(blocks: Seq[Block]): String = - blocks.map(block => printBlock(block, listLevel = 0)).mkString("\n") - - private def listBlocksIndent( - blocks: Seq[Block], - isOrdered: Boolean, - listLevel: Int - ) = { - var index = 1 - - for (block <- blocks) yield { - val ident = - block match { - case _: OrderedList | _: UnorderedList => "" - case _ => - val bullet = if (isOrdered) index.toString() else "-" - index += 1 - s"""${"\t" * listLevel}${bullet} """ - } - s"${ident}${printBlock(block, listLevel + 1)}" - } - } - - private def printBlock(block: Block, listLevel: Int): String = - block match { - case Title(text, _) => - s"""==${printInline(text)}==""" - case UnorderedList(blocks) => - this.listBlocksIndent(blocks, isOrdered = false, listLevel).mkString - case OrderedList(blocks, _) => - this.listBlocksIndent(blocks, isOrdered = true, listLevel).mkString - case Paragraph(text) => s"${printInline(text)}" - case Code(data) => s"{{{\n$data\n}}}" - case _ => "" - } - - private def printInline(i: Inline): String = - i match { - case Chain(items) => items.map(printInline).mkString - case Summary(text) => printInline(text) - case Monospace(text) => printInline(text) - case Italic(text) => printInline(text) - case Bold(text) => printInline(text) - case Link(_, title) => s"[[${printInline(title)}]]" - case Text(text) => text - case HtmlTag(data) => data - case _ => "" - } -} diff --git a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/MarkdownGenerator.scala b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/MarkdownGenerator.scala new file mode 100644 index 00000000000..60bff49e9cb --- /dev/null +++ b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/MarkdownGenerator.scala @@ -0,0 +1,86 @@ +package scala.meta.internal.docstrings.printers + +import scala.collection.Seq + +import scala.meta._ +import scala.meta.dialects.Scala213 +import scala.meta.internal.docstrings._ + +/** + * Generates markdown from the docstring + * The markdown can be returned to the IDE and rendered to the user + */ +object MarkdownGenerator extends ScalaDocPrinter { + + /** + * Generates markdown from code + * + * @param code the input code + * @return a sequence of markdown strings - one per docstring comment in the code + */ + def toText(code: String): Seq[String] = + Scala213(code).tokenize.get.collect { + case c: Token.Comment if c.syntax.startsWith("/**") => + fromDocstring(c.syntax, Map.empty) + } + + def fromDocstring( + docstring: String, + defines: collection.Map[String, String] + ): String = { + super.toText(ScaladocParser.parseComment(docstring, defines), docstring) + } + + protected def blockToText(block: Block, listLevel: Int): String = + block match { + case Title(text, level) => + s"""${"#" * level} ${inlineToText(text)}""" + case UnorderedList(blocks) => + listBlocksIndent(blocks, ListType.Bullet('-'), listLevel) + case OrderedList(blocks, _) => + listBlocksIndent(blocks, ListType.Bullet('*'), listLevel) + case Paragraph(text) => + s"${inlineToText(text)}\n" + case Code(data) => + s"```\n$data\n```" + case HorizontalRule() => + "---" + case _ => + "" + } + + protected def inlineToText(i: Inline): String = { + i match { + case Chain(items) => + items.map(inlineToText).mkString + case Summary(text) => + inlineToText(text) + case Monospace(text) => + s"`${inlineToText(text)}`" + case Text(text) => + text + case HtmlTag(data) => + data + case Italic(text) => + s"*${inlineToText(text)}*" + case Bold(text) => + s"**${inlineToText(text)}**" + case Link(target, title) => + s"[${inlineToText(title)}]($target)" + case _ => + "" + } + } + + protected def wrapParam(param: String): String = s"`$param`" + protected def constructor: String = "**Constructor**" + protected def deprecated: String = "**Deprecated**" + protected def examples: String = "**Examples**\n" + override protected def notesTitle: String = "**Notes**\n" + override protected def typeParamsTitle: String = "**Type Parameters**\n" + override protected def parametersTitle: String = "**Parameters**\n" + protected def returns: String = "**Returns:**" + override protected def throwsTitle: String = "**Throws**\n" + override protected def seeTitle: String = "**See**\n" + +} diff --git a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/PlaintextGenerator.scala b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/PlaintextGenerator.scala new file mode 100644 index 00000000000..5476a426301 --- /dev/null +++ b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/PlaintextGenerator.scala @@ -0,0 +1,43 @@ +package scala.meta.internal.docstrings.printers + +import scala.meta.internal.docstrings._ + +object PlaintextGenerator extends ScalaDocPrinter { + + def blockToText(block: Block, listLevel: Int): String = + block match { + case Title(text, _) => + s"""==${inlineToText(text)}==""" + case UnorderedList(blocks) => + listBlocksIndent(blocks, ListType.Bullet('-'), listLevel) + case OrderedList(blocks, _) => + listBlocksIndent(blocks, ListType.Ordered, listLevel) + case Paragraph(text) => s"${inlineToText(text)}\n" + case Code(data) => s"{{{\n$data\n}}}\n" + case _ => "" + } + + def inlineToText(i: Inline): String = + i match { + case Chain(items) => items.map(inlineToText).mkString + case Summary(text) => inlineToText(text) + case Monospace(text) => inlineToText(text) + case Italic(text) => inlineToText(text) + case Bold(text) => inlineToText(text) + case Link(_, title) => s"[[${inlineToText(title)}]]" + case Text(text) => text + case HtmlTag(data) => data + case _ => "" + } + + protected def wrapParam(param: String): String = param + protected def constructor: String = "@constructor" + protected def deprecated: String = "@deprecated" + protected def examples: String = "@example" + override protected def note: String = "@note" + override protected def typeParam: String = "@tparam" + override protected def param: String = "@param" + protected def returns: String = "@returns" + override protected def throws: String = "@throws" + override protected def see: String = "@see" +} diff --git a/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/ScalaDocPrinter.scala b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/ScalaDocPrinter.scala new file mode 100644 index 00000000000..205fb17bd77 --- /dev/null +++ b/mtags/src/main/scala/scala/meta/internal/metals/docstrings/printers/ScalaDocPrinter.scala @@ -0,0 +1,145 @@ +package scala.meta.internal.docstrings.printers + +import scala.collection.Seq +import scala.util.matching.Regex + +import scala.meta.internal.docstrings._ + +abstract class ScalaDocPrinter { + def toText(b: Body): String = { + Option(b) + .map(body => blocksToText(body.blocks)) + .mkString + } + + def toText(c: Comment, docstring: String): String = { + + def sortInSection( + section: String, + items: Seq[(String, Body)] + ): Seq[(String, Body)] = { + items.sortBy { case (key, _) => + val reg = new Regex(s"@$section\\s+$key") + reg.findFirstMatchIn(docstring).map(_.start).getOrElse(Int.MaxValue) + } + } + + Seq( + toText(c.body), + if (c.constructor.nonEmpty) + "\n" + c.constructor + .map(body => constructor + blocksToText(body.blocks)) + .mkString("\n") + else "", + if (c.deprecated.nonEmpty) + "\n" + c.deprecated + .map(body => deprecated ++ blocksToText(body.blocks)) + .mkString("\n") + else "", + if (c.example.nonEmpty) + s"\n$examples" + c.example + .map(body => blocksToText(body.blocks)) + .mkString("\n", "\n", "") + else "", + if (c.note.nonEmpty) + s"\n$notesTitle" + + c.note + .map(body => s"$note " + blocksToText(body.blocks)) + .mkString("\n") + else "", + if (c.typeParams.nonEmpty) + s"\n$typeParamsTitle" + + sortInSection("tparam", c.typeParams.toSeq) + .map(tuple => + s"$typeParam ${wrapParam(tuple._1)}: " + blocksToText( + tuple._2.blocks + ) + ) + .mkString + else + "", + if (c.valueParams.nonEmpty) + s"\n$parametersTitle" + sortInSection("param", c.valueParams.toSeq) + .map(tuple => + s"$param ${wrapParam(tuple._1)}: " + blocksToText(tuple._2.blocks) + ) + .mkString + else + "", + if (c.result.nonEmpty) + "\n" + c.result + .map(body => returns ++ " " ++ blocksToText(body.blocks)) + .mkString("\n") + else "", + if (c.throws.nonEmpty) + s"\n$throwsTitle" + sortInSection("throws", c.throws.toSeq) + .map(tuple => + s"$throws ${wrapParam(tuple._1)}: " + tuple._2.summary + .map(inlineToText) + .getOrElse("") + ) + .mkString("", "\n", "\n") + else "", + if (c.see.nonEmpty) + s"\n$seeTitle" + c.see + .map { body => s"$see ${blocksToText(body.blocks).trim}" } + .mkString("", "\n", "\n") + else "" + ).reduce(_ + _).trim + } + + protected def blocksToText(blocks: Seq[Block], listLevel: Int = 0): String = + blocks.map(block => blockToText(block, listLevel)).mkString("\n") + + protected def listBlocksIndent( + blocks: Seq[Block], + listType: ListType, + listLevel: Int + ): String = { + var index = 1 + + (for (block <- blocks) yield { + val ident = + block match { + case _: OrderedList | _: UnorderedList => "" + case _ => + val bullet = listType.getBullet(index) + index += 1 + s"""${"\t" * listLevel}${bullet} """ + } + s"${ident}${blockToText(block, listLevel + 1)}" + }).mkString + } + + protected def blockToText(block: Block, listLevel: Int): String + protected def inlineToText(i: Inline): String + protected def wrapParam(param: String): String + protected def constructor: String + protected def deprecated: String + protected def examples: String + protected def notesTitle: String = "" + protected def note: String = "-" + protected def typeParamsTitle: String = "" + protected def typeParam: String = "-" + protected def parametersTitle: String = "" + protected def param: String = "-" + protected def returns: String + protected def throwsTitle: String = "" + protected def throws: String = "-" + protected def seeTitle: String = "" + protected def see: String = "-" + +} + +trait ListType { + def getBullet(i: Int): String +} +object ListType { + case object Ordered extends ListType { + def getBullet(i: Int): String = i.toString() + } + + case class Bullet(c: Char) extends ListType { + def getBullet(i: Int): String = c.toString() + } +} diff --git a/tests/cross/src/test/scala/tests/hover/HoverPlaintextSuite.scala b/tests/cross/src/test/scala/tests/hover/HoverPlaintextSuite.scala index e756aedf1eb..b3e32ab67e7 100644 --- a/tests/cross/src/test/scala/tests/hover/HoverPlaintextSuite.scala +++ b/tests/cross/src/test/scala/tests/hover/HoverPlaintextSuite.scala @@ -52,17 +52,22 @@ class HoverPlaintextSuite extends BaseHoverSuite { |Returns the result of applying f to this [[scala.Option]]'s | value if the [[scala.Option]] is nonempty. Otherwise, evaluates | expression ifEmpty. + | |This is equivalent to: + | |{{{ |option match { | case Some(x) => f(x) | case None => ifEmpty |} |}}} + | |This is also equivalent to: + | |{{{ |option map f getOrElse ifEmpty |}}} + | |@param ifEmpty: the expression to evaluate if empty. |@param f: the function to apply if nonempty. |""".stripMargin @@ -80,7 +85,9 @@ class HoverPlaintextSuite extends BaseHoverSuite { | |Selects the first element of this iterable collection. | Note: might return different results for different runs, unless the underlying collection type is ordered. + | |@returns the first element of this iterable collection. + | |@throws NoSuchElementException: if the iterable collection is empty. |""".stripMargin ) diff --git a/tests/unit/src/test/scala/tests/JavadocSuite.scala b/tests/unit/src/test/scala/tests/JavadocSuite.scala index f28682f3301..6d49a6ab88b 100644 --- a/tests/unit/src/test/scala/tests/JavadocSuite.scala +++ b/tests/unit/src/test/scala/tests/JavadocSuite.scala @@ -10,7 +10,7 @@ class JavadocSuite extends BaseSuite { loc: Location ): Unit = { test(name) { - val obtained = MarkdownGenerator.toMarkdown(original).mkString + val obtained = MarkdownGenerator.toText(original).mkString assertNoDiff(obtained, expected) } }