From e5215261c4c42f2583f4b4e71a6335d8bdeb2104 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Mon, 22 Feb 2016 16:57:39 +0100 Subject: Add doc annotation `@shortDescription` to enable explicit synopsis Entities with this annotation will be able to control what is shown in the method summary on entity pages as well as the hover text on search results. Review: @VladUreche --- test/scaladoc/run/SI-9620.scala | 1 - .../scaladoc/run/shortDescription-annotation.check | 1 + .../scaladoc/run/shortDescription-annotation.scala | 55 ++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 test/scaladoc/run/shortDescription-annotation.check create mode 100644 test/scaladoc/run/shortDescription-annotation.scala (limited to 'test/scaladoc/run') diff --git a/test/scaladoc/run/SI-9620.scala b/test/scaladoc/run/SI-9620.scala index 96260aad9a..cac34d1c18 100644 --- a/test/scaladoc/run/SI-9620.scala +++ b/test/scaladoc/run/SI-9620.scala @@ -21,7 +21,6 @@ object Test extends ScaladocModelTest { } """ - // no need for special settings def scaladocSettings = "-implicits" def testModel(rootPackage: Package) = { diff --git a/test/scaladoc/run/shortDescription-annotation.check b/test/scaladoc/run/shortDescription-annotation.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/shortDescription-annotation.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/shortDescription-annotation.scala b/test/scaladoc/run/shortDescription-annotation.scala new file mode 100644 index 0000000000..0e2950f4f9 --- /dev/null +++ b/test/scaladoc/run/shortDescription-annotation.scala @@ -0,0 +1,55 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + package a + + /** This comment should not appear + * @shortDescription This one should appear + */ + class Foo { + /** This comment should appear */ + def foo: Int = 1 + + /** This comment should not appear + * @shortDescription This comment should appear + */ + def goo: Int = 2 + } + """ + + // no need for special settings + def scaladocSettings = "" + + def testModel(rootPackage: Package) = { + import scala.tools.nsc.doc.base.comment._ + import access._ + + def inlineToStr(inl: Inline): String = inl match { + case Chain(items) => items flatMap (inlineToStr(_)) mkString "" + case Italic(in) => inlineToStr(in) + case Bold(in) => inlineToStr(in) + case Underline(in) => inlineToStr(in) + case Monospace(in) => inlineToStr(in) + case Text(text) => text + case Summary(in) => inlineToStr(in) + case EntityLink(Text(text), _) => text + case _ => inl.toString + } + + val foo = rootPackage._package("a")._class("Foo") + + // Assert that the class has the correct short description + val classDesc = inlineToStr(foo.comment.get.short) + assert(classDesc == "This one should appear", classDesc) + + // Assert that the `foo` method has the correct short description + val fooDesc = inlineToStr(foo._method("foo").comment.get.short) + assert(fooDesc == "This comment should appear", fooDesc) + + // Assert that the `goo` method has the correct short description + val gooDesc = inlineToStr(foo._method("goo").comment.get.short) + assert(gooDesc == "This comment should appear", gooDesc) + } +} -- cgit v1.2.3