1
import scala.tools.nsc.doc.model._
2
import scala.tools.partest.ScaladocModelTest
4
object Test extends ScaladocModelTest {
6
override def code = """
7
package test.scaladoc {
9
/** @groupname Z From owner chain */
10
package object `groups`
15
* @groupdesc A Group A is the group that contains functions starting with f
20
* @groupdesc B Group B is the group that contains functions starting with b
21
* @groupname B Group B has a nice new name and a high priority
24
* @note This is a note
38
* @groupdesc C Group C is introduced by B
46
/** The class C which inherits from both A and B
48
* @groupdesc B Look ma, I'm overriding group descriptions!!!
49
* @groupname B And names
51
class C extends A with B {
52
/** Oh noes, I lost my group -- or did I?!? */
59
// no need for special settings
60
def scaladocSettings = "-feature"
62
def testModel(rootPackage: Package) = {
63
// get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s))
66
// just need to check the member exists, access methods will throw an error if there's a problem
67
val base = rootPackage._package("test")._package("scaladoc")._package("groups")
69
def checkGroup(mbr: MemberEntity, grp: String) =
70
assert(mbr.group == grp, "Incorrect group for " + mbr.qualifiedName + ": " + mbr.group + " instead of " + grp)
72
def checkGroupDesc(dtpl: DocTemplateEntity, grp: String, grpDesc: String) = {
73
assert(dtpl.groupDescription(grp).isDefined,
74
"Group description for " + grp + " not defined in " + dtpl.qualifiedName)
75
assert(extractCommentText(dtpl.groupDescription(grp).get).contains(grpDesc),
76
"Group description for " + grp + " in " + dtpl.qualifiedName + " does not contain \"" + grpDesc + "\": \"" +
77
extractCommentText(dtpl.groupDescription(grp).get) + "\"")
80
def checkGroupName(dtpl: DocTemplateEntity, grp: String, grpName: String) =
81
// TODO: See why we need trim here, we already do trimming in the CommentFactory
82
assert(dtpl.groupName(grp) == grpName,
83
"Group name for " + grp + " in " + dtpl.qualifiedName + " does not equal \"" + grpName + "\": \"" + dtpl.groupName(grp) + "\"")
85
def checkGroupPrio(dtpl: DocTemplateEntity, grp: String, grpPrio: Int) =
86
assert(dtpl.groupPriority(grp) == grpPrio,
87
"Group priority for " + grp + " in " + dtpl.qualifiedName + " does not equal " + grpPrio + ": " + dtpl.groupPriority(grp))
90
val A = base._trait("A")
91
val B = base._trait("B")
92
val C = base._class("C")
93
checkGroup(A, "Traits")
94
checkGroup(B, "Traits")
95
checkGroup(C, "Classes")
96
checkGroup(A._method("foo"), "A")
97
checkGroup(A._method("bar"), "B")
98
checkGroup(B._method("baz"), "C")
99
checkGroup(C._method("foo"), "A")
100
checkGroup(C._method("bar"), "B")
101
checkGroup(C._method("baz"), "C")
103
checkGroupDesc(A, "A", "Group A is the group that contains functions starting with f")
104
checkGroupName(A, "A", "A")
105
checkGroupPrio(A, "A", 0)
106
checkGroupDesc(A, "B", "Group B is the group that contains functions starting with b")
107
checkGroupName(A, "B", "Group B has a nice new name and a high priority")
108
checkGroupPrio(A, "B", -10)
109
checkGroupName(A, "Z", "From owner chain")
111
checkGroupDesc(B, "C", "Group C is introduced by B")
112
checkGroupName(B, "C", "C")
113
checkGroupPrio(B, "C", 0)
114
checkGroupName(B, "Z", "From owner chain")
116
checkGroupDesc(C, "A", "Group A is the group that contains functions starting with f")
117
checkGroupName(C, "A", "A")
118
checkGroupPrio(C, "A", 0)
119
checkGroupDesc(C, "B", "Look ma, I'm overriding group descriptions!!!")
120
checkGroupName(C, "B", "And names")
121
checkGroupPrio(C, "B", -10)
122
checkGroupDesc(C, "C", "Group C is introduced by B")
123
checkGroupName(C, "C", "C")
124
checkGroupPrio(C, "C", 0)
125
checkGroupName(C, "Z", "From owner chain")
b'\\ No newline at end of file'