From 8c63d66265ec3ef8c90f15bf908ded424f80e7de Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Sun, 3 Apr 2016 18:25:24 +0200 Subject: Fix incorrect svg on objects with companion traits --- .../scala/tools/nsc/doc/html/HtmlFactory.scala | 1 + .../scala/tools/nsc/doc/html/HtmlPage.scala | 31 ++---------- .../scala/tools/nsc/doc/html/page/Entity.scala | 7 ++- .../doc/html/resource/lib/object_comp_trait.svg | 57 ++++++++++++++++++++++ .../tools/nsc/doc/html/resource/lib/template.css | 10 ++-- 5 files changed, 71 insertions(+), 35 deletions(-) create mode 100644 src/scaladoc/scala/tools/nsc/doc/html/resource/lib/object_comp_trait.svg (limited to 'src/scaladoc') diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala index 9d61cd2e2b..b5d5163088 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlFactory.scala @@ -33,6 +33,7 @@ class HtmlFactory(val universe: doc.Universe, val reporter: ScalaDocReporter) { "class_comp.svg", "object_comp.svg", "trait_comp.svg", + "object_comp_trait.svg", "abstract_type.svg", "lato-v11-latin-100.eot", "lato-v11-latin-100.ttf", diff --git a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala index 038d85b7a8..0f37f86b3e 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/HtmlPage.scala @@ -216,34 +216,6 @@ abstract class HtmlPage extends Page { thisPage => val Trait, Class, Type, Object, Package = Value } - /** Returns the _big image name and the alt attribute - * corresponding to the DocTemplate Entity (upper left icon) */ - def docEntityKindToBigImage(ety: DocTemplateEntity) = { - def entityToImage(e: DocTemplateEntity) = - if (e.isTrait) Image.Trait - else if (e.isClass) Image.Class - else if (e.isAbstractType || e.isAliasType) Image.Type - else if (e.isObject) Image.Object - else if (e.isPackage) Image.Package - else { - // FIXME: an entity *should* fall into one of the above categories, - // but AnyRef is somehow not - Image.Class - } - - val image = entityToImage(ety) - val companionImage = ety.companion filter { - e => e.visibility.isPublic && ! e.inSource.isEmpty - } map { entityToImage } - - (image, companionImage) match { - case (from, Some(to)) => - ((from + "_to_" + to + "_big.png").toLowerCase, from + "/" + to) - case (from, None) => - ((from + "_big.png").toLowerCase, from.toString) - } - } - def permalink(template: Entity, isSelf: Boolean = true): Elem = @@ -251,6 +223,9 @@ abstract class HtmlPage extends Page { thisPage => + def docEntityImageClass(tpl: DocTemplateEntity): String = + tpl.kind + tpl.companion.fold("")("-companion-" + _.kind) + def docEntityKindToCompanionTitle(ety: DocTemplateEntity, baseString: String = "See companion") = ety.companion match{ case Some(companion) => diff --git a/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala b/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala index 6076945929..836d1b4b7d 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala +++ b/src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala @@ -216,14 +216,13 @@ trait EntityPage extends HtmlPage {
{ - val (src, alt) = docEntityKindToBigImage(tpl) - val identifier = alt.toString.substring(0,2).toLowerCase + val imageClass = docEntityImageClass(tpl) tpl.companion match { case Some(companion) if (companion.visibility.isPublic && companion.inSource != None) => -
{ identifier.substring(0,1) }
+
{ imageClass.substring(0,1) }
case _ => -
{ identifier.substring(0,1) }
+
{ imageClass.substring(0,1) }
} } { owner } diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/object_comp_trait.svg b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/object_comp_trait.svg new file mode 100644 index 0000000000..56eccd03ba --- /dev/null +++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/object_comp_trait.svg @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + O + + + + + + + + diff --git a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.css b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.css index def2da65e7..f222749dd2 100644 --- a/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.css +++ b/src/scaladoc/scala/tools/nsc/doc/html/resource/lib/template.css @@ -216,18 +216,22 @@ span.symbol > a { background: url("class.svg") no-repeat center; } -.big-circle.cl.companion { +.big-circle.class-companion-object { background: url("class_comp.svg") no-repeat center; } -.big-circle.ob.companion { +.big-circle.object-companion-class { background: url("object_comp.svg") no-repeat center; } -.big-circle.tr.companion { +.big-circle.trait-companion-object { background: url("trait_comp.svg") no-repeat center; } +.big-circle.object-companion-trait { + background: url("object_comp_trait.svg") no-repeat center; +} + .big-circle.object { background: url("object.svg") no-repeat center; } -- cgit v1.2.3