diff options
author | Vlad Ureche <vlad.ureche@gmail.com> | 2012-06-28 00:03:56 +0200 |
---|---|---|
committer | Vlad Ureche <vlad.ureche@gmail.com> | 2012-07-02 13:34:15 +0200 |
commit | f8cb1aee92fa19e38a1481a4e614cd866ef238c0 (patch) | |
tree | 00bfb3a2f355f4fa4923e3aa5390eaa4975f7187 /test/scaladoc | |
parent | f8057d22235c77d69d72d6ea4d4ebdc2eeb95cdf (diff) | |
download | scala-f8cb1aee92fa19e38a1481a4e614cd866ef238c0.tar.gz scala-f8cb1aee92fa19e38a1481a4e614cd866ef238c0.tar.bz2 scala-f8cb1aee92fa19e38a1481a4e614cd866ef238c0.zip |
Diagram tweaks #1
- relaxed the restrictions on nodes - nodes can be classes, traits and
objects, both stand-alone and companion objects -- all are added to the
diagram, but usually companion objects are filtered out as they don't
have any superclasses
- changed the rules for default diagram creation:
- classes and traits (and AnyRef) get inheritance diagrams
- packages and objects get content diagrams
(can be overridden by @contentDiagram [hideDiagram] and
@inheritanceDiagram [hideDiagram])
- tweaked the model to register subclasses of Any
- hardcoded the scala package diagram to show all relations
- enabled @contentDiagram showInheritedNodes by default and changed
the setting to hideInheritedNodes (and added a test for this)
- better node selection (can select nodes that don't have a
corresponding trait)
- fixed the docsite link in member selection, which was broken since
the first commit :))
Diffstat (limited to 'test/scaladoc')
-rw-r--r-- | test/scaladoc/run/diagrams-filtering.scala | 8 | ||||
-rw-r--r-- | test/scaladoc/run/diagrams-inherited-nodes.check | 1 | ||||
-rw-r--r-- | test/scaladoc/run/diagrams-inherited-nodes.scala | 69 |
3 files changed, 74 insertions, 4 deletions
diff --git a/test/scaladoc/run/diagrams-filtering.scala b/test/scaladoc/run/diagrams-filtering.scala index dfde5cac52..8cb32180a1 100644 --- a/test/scaladoc/run/diagrams-filtering.scala +++ b/test/scaladoc/run/diagrams-filtering.scala @@ -54,11 +54,11 @@ object Test extends ScaladocModelTest { assert(packDiag.edges.map(_._2.length).sum == 5) // trait A - // Assert we have just 2 nodes and 1 edge + // Assert we have just 3 nodes and 2 edges val A = base._trait("A") val ADiag = A.inheritanceDiagram.get - assert(ADiag.nodes.length == 2) - assert(ADiag.edges.map(_._2.length).sum == 1) + assert(ADiag.nodes.length == 3) + assert(ADiag.edges.map(_._2.length).sum == 2) // trait C val C = base._trait("C") @@ -82,7 +82,7 @@ object Test extends ScaladocModelTest { val (outgoingSuperclass, outgoingImplicit) = outgoing.head._2.partition(_.isNormalNode) assert(outgoingSuperclass.length == 2) // B and C - assert(outgoingImplicit.length == 1) // T + assert(outgoingImplicit.length == 1, outgoingImplicit) // T val (incomingSubclass, incomingImplicit) = incoming.partition(_._1.isNormalNode) assert(incomingSubclass.length == 2) // F and G diff --git a/test/scaladoc/run/diagrams-inherited-nodes.check b/test/scaladoc/run/diagrams-inherited-nodes.check new file mode 100644 index 0000000000..619c56180b --- /dev/null +++ b/test/scaladoc/run/diagrams-inherited-nodes.check @@ -0,0 +1 @@ +Done. diff --git a/test/scaladoc/run/diagrams-inherited-nodes.scala b/test/scaladoc/run/diagrams-inherited-nodes.scala new file mode 100644 index 0000000000..8ac382aab8 --- /dev/null +++ b/test/scaladoc/run/diagrams-inherited-nodes.scala @@ -0,0 +1,69 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.nsc.doc.model.diagram._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + + override def code = """ + package scala.test.scaladoc.diagrams.inherited.nodes { + + /** @contentDiagram + * @inheritanceDiagram hideDiagram */ + trait T1 { + trait A1 + trait A2 extends A1 + trait A3 extends A2 + } + + /** @contentDiagram + * @inheritanceDiagram hideDiagram */ + trait T2 extends T1 { + trait B1 extends A1 + trait B2 extends A2 with B1 + trait B3 extends A3 with B2 + } + + /** @contentDiagram + * @inheritanceDiagram hideDiagram */ + trait T3 { + self: T1 with T2 => + trait C1 extends B1 + trait C2 extends B2 with C1 + trait C3 extends B3 with C2 + } + + /** @contentDiagram + * @inheritanceDiagram hideDiagram */ + trait T4 extends T3 with T2 with T1 { + trait D1 extends C1 + trait D2 extends C2 with D1 + trait D3 extends C3 with D2 + } + } + """ + + // diagrams must be started. In case there's an error with dot, it should not report anything + def scaladocSettings = "-diagrams" + + def testModel(rootPackage: Package) = { + // get the quick access implicit defs in scope (_package(s), _class(es), _trait(s), object(s) _method(s), _value(s)) + import access._ + + // base package + // Assert we have 7 nodes and 6 edges + val base = rootPackage._package("scala")._package("test")._package("scaladoc")._package("diagrams")._package("inherited")._package("nodes") + + def checkDiagram(t: String, nodes: Int, edges: Int) = { + // trait T1 + val T = base._trait(t) + val TDiag = T.contentDiagram.get + assert(TDiag.nodes.length == nodes, t + ": " + TDiag.nodes + ".length == " + nodes) + assert(TDiag.edges.map(_._2.length).sum == edges, t + ": " + TDiag.edges.mkString("List(\n", ",\n", "\n)") + ".map(_._2.length).sum == " + edges) + } + + checkDiagram("T1", 3, 2) + checkDiagram("T2", 6, 7) + checkDiagram("T3", 3, 2) + checkDiagram("T4", 12, 17) + } +}
\ No newline at end of file |