Skip to content

Commit ecb6631

Browse files
committed
Merge pull request scala#3441 from gourlaysama/t7124
SI-7124 make macro definitions prettier in scaladoc
2 parents 1e82fd8 + a9e9035 commit ecb6631

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/scaladoc/scala/tools/nsc/doc/model/ModelFactory.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import diagram._
1010

1111
import scala.collection._
1212
import scala.util.matching.Regex
13+
import scala.reflect.macros.internal.macroImpl
1314
import symtab.Flags
1415

1516
import io._
@@ -80,7 +81,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
8081
def inTemplate: TemplateImpl = inTpl
8182
def toRoot: List[EntityImpl] = this :: inTpl.toRoot
8283
def qualifiedName = name
83-
def annotations = sym.annotations.map(makeAnnotation)
84+
def annotations = sym.annotations.filterNot(_.tpe =:= typeOf[macroImpl]).map(makeAnnotation)
8485
def inPackageObject: Boolean = sym.owner.isModuleClass && sym.owner.sourceModule.isPackageObject
8586
def isType = sym.name.isTypeName
8687
}
@@ -145,6 +146,7 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
145146
* any abstract terms, otherwise it would fail compilation. So we reset the DEFERRED flag. */
146147
if (!sym.isTrait && (sym hasFlag Flags.DEFERRED) && (!isImplicitlyInherited)) fgs += Paragraph(Text("abstract"))
147148
if (!sym.isModule && (sym hasFlag Flags.FINAL)) fgs += Paragraph(Text("final"))
149+
if (sym.isMacro) fgs += Paragraph(Text("macro"))
148150
fgs.toList
149151
}
150152
def deprecation =

test/scaladoc/run/t7124.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
List()
2+
List(Paragraph(Text(macro)))
3+
Done.

test/scaladoc/run/t7124.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import scala.tools.nsc.doc.model._
2+
import scala.tools.partest.ScaladocModelTest
3+
4+
object Test extends ScaladocModelTest {
5+
6+
override def code = """
7+
import scala.language.experimental.macros
8+
class Test {
9+
def print(): Unit = macro ???
10+
}
11+
"""
12+
13+
def scaladocSettings = ""
14+
15+
def testModel(root: Package) = {
16+
import access._
17+
val p = root._class("Test")._method("print")
18+
19+
println(p.annotations) // no annotations
20+
println(p.flags) // a 'macro' flag
21+
}
22+
}

0 commit comments

Comments
 (0)