Skip to content

Commit f6b5c2d

Browse files
committed
Clean up unused code
1 parent 4bf1030 commit f6b5c2d

File tree

4 files changed

+10
-177
lines changed

4 files changed

+10
-177
lines changed

scala3doc/src/dotty/dokka/translators/ScalaContentBuilder.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class ScalaPageContentBuilder(
2626
val signatureProvider: SignatureProvider
2727
)(using DocContext) {
2828

29+
def mkMemberInfo(m: Member) = MemberInfo(m, ContentNodeParams(
30+
new DCI(JSet(m.dri), ContentKind.Main),
31+
m.getSourceSets.asScala.toSet.toDisplay,
32+
Set(),
33+
PropertyContainer.Companion.empty()
34+
))
35+
2936
def contentForDRI(
3037
dri: DRI,
3138
sourceSets: Set[DokkaConfiguration$DokkaSourceSet],

scala3doc/src/dotty/dokka/translators/ScalaPageCreator.scala

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class ScalaPageCreator(
4343
override def pageForPackage(p: DPackage): PackagePageNode =
4444
PackagePageNode(
4545
p.name,
46-
contentForPackage(p),
46+
contentBuilder.mkMemberInfo(p),
4747
JSet(p.dri),
4848
p,
4949
pagesForMembers(p),
@@ -59,16 +59,14 @@ class ScalaPageCreator(
5959
// Hack, need our own page!
6060
ClasslikePageNode(
6161
name,
62-
contentForClass(c.asInstanceOf[DClass]),
62+
contentBuilder.mkMemberInfo(c),
6363
JSet(c.getDri),
6464
c.asInstanceOf[DClass],
6565
JNil,
6666
JNil,
6767
).modified(name, pagesForMembers(c)) // We need override default page
6868
}
6969

70-
override def pageForFunction(f: DFunction) = super.pageForFunction(f)
71-
7270
override def contentForModule(m: DModule) = {
7371
def buildBlock = (builder: DocBuilder) => builder
7472
.group(kind = ContentKind.Cover) { gbuilder => gbuilder
@@ -89,16 +87,6 @@ class ScalaPageCreator(
8987

9088
contentBuilder.contentForDocumentable(m, buildBlock = buildBlock)
9189
}
92-
93-
override def contentForPackage(p: DPackage) =
94-
contentBuilder.contentForDocumentable(p, buildBlock = _.contentForDescription(p))
95-
96-
override def contentForClasslike(c: DClasslike) = throw UnsupportedOperationException(
97-
s"Unable to generate DClasslike using default dokka method for $c!")
98-
99-
def contentForClass(c: DClass) =
100-
contentBuilder.contentForDocumentable(c, buildBlock = _.contentForDescription(c))
101-
10290
extension (b: DocBuilder)
10391
def descriptionIfNotEmpty(d: Documentable): DocBuilder = {
10492
val desc = this.contentForDescription(d).asScala.toSeq
@@ -113,103 +101,3 @@ class ScalaPageCreator(
113101
}
114102
res
115103
}
116-
117-
def contentForDescription(m: Member) = b.memberInfo(m)
118-
119-
def contentForScope(s: Documentable & WithScope & WithExtraProperties[_]) =
120-
def groupExtensions(extensions: Seq[Member]): Seq[DocumentableSubGroup] =
121-
extensions.groupBy(_.kind).map {
122-
case (Kind.Extension(on, _), members) =>
123-
val signature = Signature(s"extension (${on.name}: ") join on.signature join Signature(")")
124-
DocumentableSubGroup(signature, members.toSeq)
125-
case other => sys.error(s"unexpected value: $other")
126-
}.toSeq
127-
128-
val (definedMethods, inheritedMethods) = s.membersBy(_.kind.isInstanceOf[Kind.Def]).byInheritance
129-
val (definedFields, inheritedFiles) = s.membersBy(m => m.kind == Kind.Val || m.kind == Kind.Var).byInheritance
130-
val (definedClasslikes, inheritedClasslikes) = s.membersBy(m => m.kind.isInstanceOf[Classlike]).byInheritance
131-
val (definedTypes, inheritedTypes) = s.membersBy(_.kind.isInstanceOf[Kind.Type]).byInheritance
132-
val (definedGivens, inheritedGives) = s.membersBy(_.kind.isInstanceOf[Kind.Given]).byInheritance
133-
val (definedExtensions, inheritedExtensions) = s.membersBy(_.kind.isInstanceOf[Kind.Extension]).byInheritance
134-
val (definedExports, inheritedExports) = s.membersBy(_.kind.isInstanceOf[Kind.Exported]).byInheritance
135-
val (definedImplicits, inheritedImplicits) = s.membersBy(_.kind.isInstanceOf[Kind.Implicit]).byInheritance
136-
137-
b
138-
.documentableTab("Type members")(
139-
DocumentableGroup(Some("Types"), definedTypes),
140-
DocumentableGroup(Some("Classlikes"), definedClasslikes),
141-
DocumentableGroup(Some("Inherited types"), inheritedTypes),
142-
DocumentableGroup(Some("Inherited classlikes"), inheritedClasslikes)
143-
)
144-
.documentableTab("Methods")(
145-
DocumentableGroup(Some("Defined methods"), definedMethods),
146-
DocumentableGroup(Some("Inherited methods"), inheritedMethods),
147-
)
148-
.documentableTab("Value members")(
149-
DocumentableGroup(Some("Defined value members"), definedFields),
150-
DocumentableGroup(Some("Inherited value members"), inheritedFiles)
151-
)
152-
.documentableTab("Givens")(
153-
DocumentableGroup(Some("Defined givens"), definedGivens),
154-
DocumentableGroup(Some("Inherited givens"), inheritedGives)
155-
)
156-
.documentableTab("Extensions")(
157-
DocumentableGroup(Some("Defined extensions"), groupExtensions(definedExtensions)),
158-
DocumentableGroup(Some("Inherited extensions"), groupExtensions(inheritedExtensions))
159-
)
160-
.documentableTab("Implicits")(
161-
DocumentableGroup(Some("Defined implicits"), definedImplicits),
162-
DocumentableGroup(Some("Inherited implicits"), inheritedImplicits)
163-
)
164-
.documentableTab("Exports")(
165-
DocumentableGroup(Some("Defined exports"), definedExports),
166-
DocumentableGroup(Some("Inherited exports"), inheritedExports),
167-
)
168-
169-
170-
def contentForEnum(c: DClass) =
171-
b.documentableTab("Enum entries")(
172-
DocumentableGroup(None, c.membersBy(_.kind == Kind.EnumCase)) // Enum entries cannot be inherited
173-
)
174-
175-
176-
def contentForConstructors(c: DClass) =
177-
b.documentableTab("Constructors")(
178-
DocumentableGroup(None, c.membersBy(_.kind.isInstanceOf[Kind.Constructor]))
179-
)
180-
181-
182-
def contentForTypesInfo(c: DClass) =
183-
val supertypes = c.parents
184-
val subtypes = c.knownChildren
185-
186-
def contentForTypeLink(builder: DocBuilder, link: LinkToType): DocBuilder =
187-
builder.group(styles = Set(TextStyle.Paragraph)) { builder =>
188-
link.signature.foldLeft(builder.text(link.kind.name).text(" ")){ (builder, sigElement) => sigElement match
189-
case Link(name, dri) => builder.driLink(name, dri)
190-
case str: String => builder.text(str)
191-
}
192-
}
193-
194-
val withSupertypes = if supertypes.isEmpty then b else
195-
b.header(2, "Linear supertypes")()
196-
.group(
197-
kind = ContentKind.Comment,
198-
styles = Set(ContentStyle.WithExtraAttributes),
199-
extra = PropertyContainer.Companion.empty plus SimpleAttr.Companion.header("Linear supertypes")
200-
){ gbdr => gbdr
201-
.group(kind = ContentKind.Symbol, styles = Set(TextStyle.Monospace)){ grbdr => grbdr
202-
.list(supertypes.toList, separator = "")(contentForTypeLink)
203-
}
204-
}
205-
206-
val withSubtypes = if (subtypes.isEmpty) withSupertypes else
207-
withSupertypes.header(2, "Known subtypes")()
208-
.group(
209-
kind = ContentKind.Comment,
210-
styles = Set(ContentStyle.WithExtraAttributes),
211-
extra = PropertyContainer.Companion.empty plus SimpleAttr.Companion.header("Known subtypes")
212-
) { _.group(kind = ContentKind.Symbol, styles = Set(TextStyle.Monospace)) {
213-
_.list(subtypes.toList, separator="")(contentForTypeLink)
214-
}
215-
}

scala3doc/src/dotty/renderers/MemberRenderer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer, buildNode: ContentNod
267267
buildGroup("Type members", Seq(
268268
("Classlikes", rest.filter(m => m.kind.isInstanceOf[Classlike])),
269269
("Types", rest.filter(_.kind.isInstanceOf[Kind.Type])),
270+
("Enum entries", rest.filter(_.kind == Kind.EnumCase)),
270271
)),
271272
buildGroup("Value members", Seq(
272273
("Constructors", rest.filter(_.kind.isInstanceOf[Kind.Constructor])),

scala3doc/src/dotty/renderers/ScalaHtmlRenderer.scala

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -112,69 +112,6 @@ class ScalaHtmlRenderer(using ctx: DokkaContext) extends HtmlRenderer(ctx) {
112112
val renderer = SignatureRenderer(pageContext, sourceSets, getLocationProvider)
113113
(renderer, new MemberRenderer(renderer, buildWithKotlinx(_, pageContext, null)))
114114

115-
private def buildDocumentableList(n: DocumentableList, pageContext: ContentPage, sourceSetRestriciton: JSet[DisplaySourceSet]) =
116-
def render(n: ContentNode) = raw(buildWithKotlinx(n, pageContext, null))
117-
118-
val (renderer, memberRenderer) = renderers(pageContext)
119-
import renderer._
120-
121-
def buildDocumentable(element: DocumentableElement) =
122-
def topLevelAttr = Seq(cls := "documentableElement")
123-
++ element.params.dri.anchor.map(id := _)
124-
++ element.attributes.map{ case (n, v) => Attr(s"data-f-$n") := v }
125-
val kind = element.modifiers.takeRight(1)
126-
val otherModifiers = element.modifiers.dropRight(1)
127-
128-
val nameStyles = element.nameWithStyles.styles.map(_.toString.toLowerCase).mkString(" ")
129-
val nameClasses = cls := s"documentableName monospace ${nameStyles.mkString(" ")}"
130-
131-
div(topLevelAttr:_*)(
132-
a(href:=link(element.params.dri).getOrElse("#"), cls := "documentableAnchor"),
133-
div(span(cls := "annotations monospace")(element.annotations.map(renderElement))),
134-
div(cls := "header")(
135-
span(cls := "modifiers monospace")(
136-
span(cls := "other-modifiers")(otherModifiers.map(renderElement)),
137-
span(cls := "kind")(kind.map(renderElement)),
138-
),
139-
renderLink(element.nameWithStyles.name, element.params.dri, nameClasses),
140-
span(cls := "signature monospace")(element.signature.map(renderElement)),
141-
),
142-
div(cls := "docs")(
143-
span(cls := "modifiers monospace"),
144-
div(
145-
div(cls := "originInfo")(element.originInfo.map(renderElement)),
146-
div(cls := "documentableBrief")(memberRenderer.memberInfo(element.member)),
147-
)
148-
)
149-
)
150-
151-
div(cls := "documentableList", testId := "definitionList")(
152-
if(n.groupName.isEmpty) raw("") else h3(cls := "documentableHeader")(n.groupName.map(renderElement)),
153-
n.elements.flatMap {
154-
case element: DocumentableElement =>
155-
Seq(buildDocumentable(element))
156-
case group: DocumentableElementGroup =>
157-
h4(cls := "documentable-extension-target")(
158-
group.header.map(renderElement)
159-
) +: group.elements.map(buildDocumentable)
160-
}
161-
)
162-
163-
private def buildDocumentableFilter = div(cls := "documentableFilter")(
164-
div(cls := "filterUpperContainer")(
165-
button(cls := "filterToggleButton", testId := "filterToggleButton")(
166-
raw("""
167-
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
168-
<path d="M0 0h24v24H0z" fill="none"/>
169-
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
170-
</svg>
171-
""")
172-
),
173-
input(cls := "filterableInput", placeholder := "Filter all members", testId := "filterBarInput")
174-
),
175-
div(cls := "filterLowerContainer")()
176-
)
177-
178115
def buildDescriptionList(node: ContentTable, pageContext: ContentPage, sourceSetRestriciton: JSet[DisplaySourceSet]) = {
179116
val children = node.getChildren.asScala.toList.zipWithIndex
180117
val nodeStyles = node.getStyle.asScala.toSet

0 commit comments

Comments
 (0)