Skip to content

Commit c608dfc

Browse files
committed
Fix sidebar not displaying objects with no companion
1 parent 9121b46 commit c608dfc

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

src/scaladoc/scala/tools/nsc/doc/html/Page.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ abstract class Page {
102102
relativize(thisPage.path.reverse, destPath.reverse).mkString("/")
103103
}
104104

105+
def hasCompanion(mbr: TemplateEntity): Boolean = mbr match {
106+
case dtpl: DocTemplateEntity => dtpl.companion.isDefined
107+
case _ => false
108+
}
109+
105110
protected def inlineToStr(inl: comment.Inline): String = inl match {
106111
case comment.Chain(items) => items flatMap (inlineToStr(_)) mkString ""
107112
case comment.Italic(in) => inlineToStr(in)

src/scaladoc/scala/tools/nsc/doc/html/page/Entity.scala

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,24 @@ trait EntityPage extends HtmlPage {
7979
<ul>
8080
{
8181
def entityToUl(mbr: TemplateEntity with MemberEntity, indentation: Int): NodeSeq =
82-
<li class={"current-entities indented" + indentation}>
83-
{
84-
mbr match {
85-
case dtpl: DocTemplateEntity =>
86-
dtpl.companion.fold(<span class="separator"></span>) { c: DocTemplateEntity =>
87-
<a class="object" href={relativeLinkTo(c)} title={c.comment.fold("")(com => inlineToStr(com.short))}></a>
88-
}
89-
case _ => <span class="separator"></span>
82+
if (mbr.isObject && hasCompanion(mbr))
83+
NodeSeq.Empty
84+
else
85+
<li class={"current-entities indented" + indentation}>
86+
{
87+
mbr match {
88+
case dtpl: DocTemplateEntity =>
89+
dtpl.companion.fold(<span class="separator"></span>) { c: DocTemplateEntity =>
90+
<a class="object" href={relativeLinkTo(c)} title={c.comment.fold("")(com => inlineToStr(com.short))}></a>
91+
}
92+
case _ => <span class="separator"></span>
93+
}
9094
}
91-
}
92-
<a class={mbr.kind} href={relativeLinkTo(mbr)} title={mbr.comment.fold("")(com => inlineToStr(com.short))}></a>
93-
<a href={relativeLinkTo(mbr)} title={mbr.comment.fold("")(com => inlineToStr(com.short))}>
94-
{mbr.name}
95-
</a>
96-
</li>
95+
<a class={mbr.kind} href={relativeLinkTo(mbr)} title={mbr.comment.fold("")(com => inlineToStr(com.short))}></a>
96+
<a href={relativeLinkTo(mbr)} title={mbr.comment.fold("")(com => inlineToStr(com.short))}>
97+
{mbr.name}
98+
</a>
99+
</li>
97100

98101
// Get path from root
99102
val rootToParentLis = tpl.toRoot
@@ -123,7 +126,7 @@ trait EntityPage extends HtmlPage {
123126
val subsToTplLis = subsToTpl.map(memberToHtml(_, tpl, indentation = rootToParentLis.length))
124127
val subsAfterTplLis = subsAfterTpl.map(memberToHtml(_, tpl, indentation = rootToParentLis.length))
125128
val currEntityLis = currentPackageTpls
126-
.filter(x => !x.isPackage && (x.isTrait || x.isClass || x.isAbstractType))
129+
.filter(x => !x.isPackage && (x.isTrait || x.isClass || x.isAbstractType || x.isObject))
127130
.sortBy(_.name)
128131
.map(entityToUl(_, (if (tpl.isPackage) 0 else -1) + rootToParentLis.length))
129132
val currSubLis = tpl.templates

0 commit comments

Comments
 (0)