diff options
Diffstat (limited to 'src/scaladoc')
-rw-r--r-- | src/scaladoc/scala/tools/nsc/doc/Settings.scala | 5 | ||||
-rw-r--r-- | src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala | 34 |
2 files changed, 26 insertions, 13 deletions
diff --git a/src/scaladoc/scala/tools/nsc/doc/Settings.scala b/src/scaladoc/scala/tools/nsc/doc/Settings.scala index e16b6be853..e5dbaa3fd5 100644 --- a/src/scaladoc/scala/tools/nsc/doc/Settings.scala +++ b/src/scaladoc/scala/tools/nsc/doc/Settings.scala @@ -238,10 +238,7 @@ class Settings(error: String => Unit, val printMsg: String => Unit = println(_)) } } - def appendIndex(url: String): String = { - val index = "/index.html" - if (url.endsWith(index)) url else url + index - } + def appendIndex(url: String): String = url.stripSuffix("index.html").stripSuffix("/") + "/index.html" lazy val extUrlMapping: Map[String, String] = docExternalDoc.value flatMap { s => val idx = s.indexOf("#") diff --git a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala index ebac25bbe4..87d7ece8f2 100644 --- a/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala @@ -116,18 +116,27 @@ trait DiagramFactory extends DiagramDirectiveParser { case d: TemplateEntity if ((!diagramFilter.hideInheritedNodes) || (d.inTemplate == pack)) => d } + def listSuperClasses(member: MemberTemplateImpl) = { + // TODO: Everyone should be able to use the @{inherit,content}Diagram annotation to add nodes to diagrams. + (pack.sym, member.sym) match { + case (ScalaPackage, NullClass) => + List(makeTemplate(AnyRefClass)) + case (ScalaPackage, NothingClass) => + (List(NullClass) ::: ScalaValueClasses) map { makeTemplate(_) } + case _ => + member.parentTypes map { + case (template, tpe) => template + } filter { + nodesAll.contains(_) + } + } + } + // for each node, add its subclasses for (node <- nodesAll if !classExcluded(node)) { node match { case dnode: MemberTemplateImpl => - var superClasses = dnode.parentTypes.map(_._1).filter(nodesAll.contains(_)) - - // TODO: Everyone should be able to use the @{inherit,content}Diagram annotation to add nodes to diagrams. - if (pack.sym == ScalaPackage) - if (dnode.sym == NullClass) - superClasses = List(makeTemplate(AnyRefClass)) - else if (dnode.sym == NothingClass) - superClasses = (List(NullClass) ::: ScalaValueClasses).map(makeTemplate(_)) + val superClasses = listSuperClasses(dnode) if (!superClasses.isEmpty) { nodesShown += dnode @@ -149,7 +158,14 @@ trait DiagramFactory extends DiagramDirectiveParser { None else { val nodes = nodesAll.filter(nodesShown.contains(_)).flatMap(mapNodes.get(_)) - val edges = edgesAll.map(pair => (mapNodes(pair._1), pair._2.map(mapNodes(_)))).filterNot(pair => pair._2.isEmpty) + val edges = edgesAll.map { + case (entity, superClasses) => { + (mapNodes(entity), superClasses flatMap { mapNodes.get(_) }) + } + } filterNot { + case (node, superClassNodes) => superClassNodes.isEmpty + } + val diagram = // TODO: Everyone should be able to use the @{inherit,content}Diagram annotation to change the diagrams. if (pack.sym == ScalaPackage) { |