Skip to content

Commit 8bacff5

Browse files
committed
Doc-tool: Remove @sourcefile annotation
The `@sourcefile` annotation is added to symbols when they're unpickled from TASTY, and we need to remove them so that they do not appear when generating the documentation.
1 parent a48ee6d commit 8bacff5

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

doc-tool/src/dotty/tools/dottydoc/model/factories.scala

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
package dotty.tools.dottydoc
22
package model
33

4-
import comment._
54
import references._
65
import dotty.tools.dotc
76
import dotc.core.Types
87
import Types._
9-
import dotc.core.TypeApplications._
108
import dotc.core.Contexts.Context
119
import dotc.core.Symbols.{ Symbol, ClassSymbol }
1210
import dotty.tools.dotc.core.SymDenotations._
13-
import dotty.tools.dotc.config.Printers.dottydoc
14-
import dotty.tools.dotc.core.Names.TypeName
15-
import dotc.ast.Trees._
16-
import dotc.core.StdNames._
1711

1812
import scala.annotation.tailrec
1913

@@ -42,7 +36,9 @@ object factories {
4236
}
4337

4438
def annotations(sym: Symbol)(implicit ctx: Context): List[String] =
45-
sym.annotations.map(_.symbol.showFullName)
39+
sym.annotations.collect {
40+
case ann if ann.symbol != ctx.definitions.SourceFileAnnot => ann.symbol.showFullName
41+
}
4642

4743
private val product = """Product[1-9][0-9]*""".r
4844

doc-tool/test/PackageStructure.scala

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,35 @@ package dottydoc
33

44
import org.junit.Test
55
import org.junit.Assert._
6-
76
import dotc.util.SourceFile
7+
import model.Trait
88
import model.internal._
99

1010
class PackageStructureFromSourceTest extends PackageStructureBase with CheckFromSource
1111
class PackageStructureFromTastyTest extends PackageStructureBase with CheckFromTasty
1212

1313
abstract class PackageStructureBase extends DottyDocTest {
14+
15+
@Test def sourceFileAnnotIsStripped = {
16+
val source = new SourceFile(
17+
"A.scala",
18+
"""package scala
19+
|
20+
|/** Some doc */
21+
|trait A
22+
""".stripMargin
23+
)
24+
25+
val className = "scala.A"
26+
27+
check(className :: Nil, source :: Nil) { (ctx, packages) =>
28+
packages("scala") match {
29+
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
30+
assert(trt.annotations.isEmpty)
31+
}
32+
}
33+
}
34+
1435
@Test def multipleCompilationUnits = {
1536
val source1 = new SourceFile(
1637
"TraitA.scala",

0 commit comments

Comments
 (0)