Skip to content

Commit

Permalink
Doc-tool: Remove @sourcefile annotation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Duhemm committed Sep 4, 2018
1 parent a48ee6d commit 8bacff5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
10 changes: 3 additions & 7 deletions doc-tool/src/dotty/tools/dottydoc/model/factories.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
package dotty.tools.dottydoc
package model

import comment._
import references._
import dotty.tools.dotc
import dotc.core.Types
import Types._
import dotc.core.TypeApplications._
import dotc.core.Contexts.Context
import dotc.core.Symbols.{ Symbol, ClassSymbol }
import dotty.tools.dotc.core.SymDenotations._
import dotty.tools.dotc.config.Printers.dottydoc
import dotty.tools.dotc.core.Names.TypeName
import dotc.ast.Trees._
import dotc.core.StdNames._

import scala.annotation.tailrec

Expand Down Expand Up @@ -42,7 +36,9 @@ object factories {
}

def annotations(sym: Symbol)(implicit ctx: Context): List[String] =
sym.annotations.map(_.symbol.showFullName)
sym.annotations.collect {
case ann if ann.symbol != ctx.definitions.SourceFileAnnot => ann.symbol.showFullName
}

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

Expand Down
23 changes: 22 additions & 1 deletion doc-tool/test/PackageStructure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,35 @@ package dottydoc

import org.junit.Test
import org.junit.Assert._

import dotc.util.SourceFile
import model.Trait
import model.internal._

class PackageStructureFromSourceTest extends PackageStructureBase with CheckFromSource
class PackageStructureFromTastyTest extends PackageStructureBase with CheckFromTasty

abstract class PackageStructureBase extends DottyDocTest {

@Test def sourceFileAnnotIsStripped = {
val source = new SourceFile(
"A.scala",
"""package scala
|
|/** Some doc */
|trait A
""".stripMargin
)

val className = "scala.A"

check(className :: Nil, source :: Nil) { (ctx, packages) =>
packages("scala") match {
case PackageImpl(_, _, _, List(trt: Trait), _, _, _, _) =>
assert(trt.annotations.isEmpty)
}
}
}

@Test def multipleCompilationUnits = {
val source1 = new SourceFile(
"TraitA.scala",
Expand Down

0 comments on commit 8bacff5

Please sign in to comment.