From f2e0616f90f934689e4892358d56221504ad2a46 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Mon, 8 Feb 2016 13:56:16 +0100 Subject: SI-9620: add doc annotation to hide specific conversions This commit will introduce the doc annotation `@hideImplicitConversion`. By specifying which conversions to hide, the user can "toggle" which conversions are kept in the parsed entity. This implementation is a better workaround than hardcoding which ones to ignore when running scaladoc. Review: @VladUreche --- test/scaladoc/run/SI-9620.check | 1 + test/scaladoc/run/SI-9620.scala | 43 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/scaladoc/run/SI-9620.check create mode 100644 test/scaladoc/run/SI-9620.scala (limited to 'test') diff --git a/test/scaladoc/run/SI-9620.check b/test/scaladoc/run/SI-9620.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/SI-9620.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/SI-9620.scala b/test/scaladoc/run/SI-9620.scala new file mode 100644 index 0000000000..96260aad9a --- /dev/null +++ b/test/scaladoc/run/SI-9620.scala @@ -0,0 +1,43 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ + package a + + trait Foo[S] { + def foo(t: S): Int = 123 + } + + /** Boo with only one foo method, hopefully! + * @hideImplicitConversion BooShouldNotAppearIsFoo + */ + trait Boo[T] + + object Boo { + sealed trait ShouldNotAppear + implicit class BooShouldNotAppearIsFoo(boo: Boo[ShouldNotAppear]) extends Foo[ShouldNotAppear] + implicit class BooLongIsFoo(boo: Boo[Long]) extends Foo[Long] + } + """ + + // no need for special settings + def scaladocSettings = "-implicits" + + def testModel(rootPackage: Package) = { + import access._ + + // Assert Boo only has one implicit conversion + val boo = rootPackage._package("a")._trait("Boo") + val conversions = boo._conversions("a.Boo.BooShouldNotAppearIsFoo") ++ boo._conversions("a.Boo.BooLongIsFoo") + assert(conversions.length == 1, conversions.length + " == 1") + + // Assert that the implicit conversion is not "BooShouldNotAppearIsFoo" + assert(conversions.head.conversionShortName == "BooLongIsFoo", + conversions.head.conversionShortName + " == BooLongIsFoo") + + // Assert that the same for full path + assert(conversions.head.conversionQualifiedName == "a.Boo.BooLongIsFoo", + conversions.head.conversionQualifiedName + " == a.Boo.BooLongIsFoo") + } +} -- cgit v1.2.3