Skip to content

Commit

Permalink
Reorganize tabs for Classlike (#2764)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev authored Feb 24, 2023
1 parent 8d23340 commit 1040288
Show file tree
Hide file tree
Showing 28 changed files with 873 additions and 453 deletions.
33 changes: 28 additions & 5 deletions core/api/core.api
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,7 @@ public final class org/jetbrains/dokka/model/DocumentableUtilsKt {
public static final fun filter (Lorg/jetbrains/dokka/model/DTypeParameter;Ljava/util/Set;)Lorg/jetbrains/dokka/model/DTypeParameter;
public static final fun filtered (Ljava/util/Map;Ljava/util/Set;)Ljava/util/Map;
public static final fun filtered (Lorg/jetbrains/dokka/DokkaConfiguration$DokkaSourceSet;Ljava/util/Set;)Lorg/jetbrains/dokka/DokkaConfiguration$DokkaSourceSet;
public static final fun isExtension (Lorg/jetbrains/dokka/model/Documentable;)Z
}

public final class org/jetbrains/dokka/model/DoubleConstant : org/jetbrains/dokka/model/Expression {
Expand Down Expand Up @@ -3469,6 +3470,18 @@ public abstract interface class org/jetbrains/dokka/model/properties/WithExtraPr
public abstract fun withNewExtras (Lorg/jetbrains/dokka/model/properties/PropertyContainer;)Ljava/lang/Object;
}

public final class org/jetbrains/dokka/pages/BasicTabbedContentType : java/lang/Enum, org/jetbrains/dokka/pages/TabbedContentType {
public static final field CONSTRUCTOR Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static final field ENTRY Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static final field EXTENSION_FUNCTION Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static final field EXTENSION_PROPERTY Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static final field FUNCTION Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static final field PROPERTY Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static final field TYPE Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static fun valueOf (Ljava/lang/String;)Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
public static fun values ()[Lorg/jetbrains/dokka/pages/BasicTabbedContentType;
}

public abstract interface class org/jetbrains/dokka/pages/ClasslikePage : org/jetbrains/dokka/pages/ContentPage, org/jetbrains/dokka/pages/WithDocumentables {
}

Expand Down Expand Up @@ -4248,17 +4261,12 @@ public abstract class org/jetbrains/dokka/pages/RootPageNode : org/jetbrains/dok
}

public final class org/jetbrains/dokka/pages/SimpleAttr : org/jetbrains/dokka/model/properties/ExtraProperty {
public static final field Companion Lorg/jetbrains/dokka/pages/SimpleAttr$Companion;
public fun <init> (Ljava/lang/String;Ljava/lang/String;)V
public final fun getExtraKey ()Ljava/lang/String;
public final fun getExtraValue ()Ljava/lang/String;
public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key;
}

public final class org/jetbrains/dokka/pages/SimpleAttr$Companion {
public final fun header (Ljava/lang/String;)Lorg/jetbrains/dokka/pages/SimpleAttr;
}

public final class org/jetbrains/dokka/pages/SimpleAttr$SimpleAttrKey : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
public fun <init> (Ljava/lang/String;)V
public final fun component1 ()Ljava/lang/String;
Expand All @@ -4282,6 +4290,21 @@ public final class org/jetbrains/dokka/pages/SymbolContentKind : java/lang/Enum,
public static fun values ()[Lorg/jetbrains/dokka/pages/SymbolContentKind;
}

public abstract interface class org/jetbrains/dokka/pages/TabbedContentType {
}

public final class org/jetbrains/dokka/pages/TabbedContentTypeExtra : org/jetbrains/dokka/model/properties/ExtraProperty {
public static final field Companion Lorg/jetbrains/dokka/pages/TabbedContentTypeExtra$Companion;
public fun <init> (Lorg/jetbrains/dokka/pages/TabbedContentType;)V
public fun getKey ()Lorg/jetbrains/dokka/model/properties/ExtraProperty$Key;
public final fun getValue ()Lorg/jetbrains/dokka/pages/TabbedContentType;
}

public final class org/jetbrains/dokka/pages/TabbedContentTypeExtra$Companion : org/jetbrains/dokka/model/properties/ExtraProperty$Key {
public synthetic fun mergeStrategyFor (Ljava/lang/Object;Ljava/lang/Object;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
public fun mergeStrategyFor (Lorg/jetbrains/dokka/pages/TabbedContentTypeExtra;Lorg/jetbrains/dokka/pages/TabbedContentTypeExtra;)Lorg/jetbrains/dokka/model/properties/MergeStrategy;
}

public final class org/jetbrains/dokka/pages/TextStyle : java/lang/Enum, org/jetbrains/dokka/pages/Style {
public static final field Block Lorg/jetbrains/dokka/pages/TextStyle;
public static final field Bold Lorg/jetbrains/dokka/pages/TextStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public final class matchers/content/ContentMatchersDslKt {
public static final fun platformHinted (Lmatchers/content/ContentMatcherBuilder;Lkotlin/jvm/functions/Function1;)V
public static final fun skipAllNotMatching (Lmatchers/content/ContentMatcherBuilder;)V
public static final fun somewhere (Lmatchers/content/ContentMatcherBuilder;Lkotlin/jvm/functions/Function1;)V
public static final fun tab (Lmatchers/content/ContentMatcherBuilder;Lorg/jetbrains/dokka/pages/TabbedContentType;Lkotlin/jvm/functions/Function1;)V
public static final fun tabbedGroup (Lmatchers/content/ContentMatcherBuilder;Lkotlin/jvm/functions/Function1;)V
public static final fun table (Lmatchers/content/ContentMatcherBuilder;Lkotlin/jvm/functions/Function1;)V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package matchers.content
import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.isEqualTo
import assertk.assertions.isNotNull
import org.jetbrains.dokka.model.withDescendants
import org.jetbrains.dokka.pages.*
import org.jetbrains.dokka.test.tools.matchers.content.*
Expand Down Expand Up @@ -70,6 +71,23 @@ fun ContentMatcherBuilder<*>.skipAllNotMatching() {
// Convenience functions:
fun ContentMatcherBuilder<*>.group(block: ContentMatcherBuilder<ContentGroup>.() -> Unit) = composite(block)

fun ContentMatcherBuilder<*>.tabbedGroup(
block: ContentMatcherBuilder<ContentGroup>.() -> Unit
) = composite<ContentGroup> {
block()
check { assertThat(this::style).transform { style -> style.contains(ContentStyle.TabbedContent) }.isEqualTo(true) }
}

fun ContentMatcherBuilder<*>.tab(
tabbedContentType: TabbedContentType, block: ContentMatcherBuilder<ContentGroup>.() -> Unit
) = composite<ContentGroup> {
block()
check {
assertThat(this::extra).transform { extra -> extra[TabbedContentTypeExtra]?.value }
.isEqualTo(tabbedContentType)
}
}

fun ContentMatcherBuilder<*>.header(expectedLevel: Int? = null, block: ContentMatcherBuilder<ContentHeader>.() -> Unit) =
composite<ContentHeader> {
block()
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/kotlin/model/Documentable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -519,4 +519,4 @@ interface DocumentableSource {
val path: String
}

data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind)
data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind)
2 changes: 2 additions & 0 deletions core/src/main/kotlin/model/documentableUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>) =
extra
)
}

fun Documentable.isExtension() = this is Callable && receiver != null
9 changes: 8 additions & 1 deletion core/src/main/kotlin/pages/ContentNodes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,14 @@ enum class TextStyle : Style {
}

enum class ContentStyle : Style {
RowTitle, TabbedContent, WithExtraAttributes, RunnableSample, InDocumentationAnchor, Caption,
RowTitle,
/**
* The style is used only for HTML. It is applied only for [ContentGroup].
* Creating and rendering tabs is a part of a renderer.
*/
TabbedContent,

WithExtraAttributes, RunnableSample, InDocumentationAnchor, Caption,
Wrapped, Indented, KDocTag, Footnote
}

Expand Down
20 changes: 17 additions & 3 deletions core/src/main/kotlin/pages/contentNodeProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ class SimpleAttr(val extraKey: String, val extraValue: String) : ExtraProperty<C
data class SimpleAttrKey(val key: String) : ExtraProperty.Key<ContentNode, SimpleAttr>
override val key: ExtraProperty.Key<ContentNode, SimpleAttr> = SimpleAttrKey(extraKey)

companion object {
fun header(value: String) = SimpleAttr("data-togglable", value)
}
}

enum class BasicTabbedContentType : TabbedContentType {
TYPE, CONSTRUCTOR, FUNCTION, PROPERTY, ENTRY, EXTENSION_PROPERTY, EXTENSION_FUNCTION
}

/**
* It is used only to mark content for tabs in HTML format
*/
interface TabbedContentType

/**
* @see TabbedContentType
*/
class TabbedContentTypeExtra(val value: TabbedContentType) : ExtraProperty<ContentNode> {
companion object : ExtraProperty.Key<ContentNode, TabbedContentTypeExtra>
override val key: ExtraProperty.Key<ContentNode, TabbedContentTypeExtra> = TabbedContentTypeExtra
}

object HtmlContent : ExtraProperty<ContentNode>, ExtraProperty.Key<ContentNode, HtmlContent> {
Expand Down
15 changes: 6 additions & 9 deletions plugins/base/api/base.api
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public final class org/jetbrains/dokka/base/DokkaBase : org/jetbrains/dokka/plug
public final fun getDefaultExternalDocumentablesProvider ()Lorg/jetbrains/dokka/plugability/Extension;
public final fun getDefaultKotlinAnalysis ()Lorg/jetbrains/dokka/plugability/Extension;
public final fun getDefaultSamplesTransformer ()Lorg/jetbrains/dokka/plugability/Extension;
public final fun getDefaultTabSortingStrategy ()Lorg/jetbrains/dokka/plugability/Extension;
public final fun getDeprecatedDocumentableFilter ()Lorg/jetbrains/dokka/plugability/Extension;
public final fun getDescriptorToDocumentableTranslator ()Lorg/jetbrains/dokka/plugability/Extension;
public final fun getDocTagToContentConverter ()Lorg/jetbrains/dokka/plugability/Extension;
Expand Down Expand Up @@ -272,11 +271,6 @@ public final class org/jetbrains/dokka/base/renderers/DefaultRendererKt {
public static final fun sourceSets (Lorg/jetbrains/dokka/pages/ContentPage;)Ljava/util/Set;
}

public final class org/jetbrains/dokka/base/renderers/DefaultTabSortingStrategy : org/jetbrains/dokka/base/renderers/TabSortingStrategy {
public fun <init> ()V
public fun sort (Ljava/util/Collection;)Ljava/util/List;
}

public final class org/jetbrains/dokka/base/renderers/FileWriter : org/jetbrains/dokka/base/renderers/OutputWriter {
public fun <init> (Lorg/jetbrains/dokka/plugability/DokkaContext;)V
public final fun getContext ()Lorg/jetbrains/dokka/plugability/DokkaContext;
Expand Down Expand Up @@ -1450,16 +1444,19 @@ public class org/jetbrains/dokka/base/translators/documentables/DefaultPageCreat
public synthetic fun <init> (Lorg/jetbrains/dokka/base/DokkaBaseConfiguration;Lorg/jetbrains/dokka/base/transformers/pages/comments/CommentsToContentConverter;Lorg/jetbrains/dokka/base/signatures/SignatureProvider;Lorg/jetbrains/dokka/utilities/DokkaLogger;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
protected fun contentForBrief (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Lorg/jetbrains/dokka/model/Documentable;)V
protected fun contentForClasslikesAndEntries (Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForConstructors (Ljava/util/List;Ljava/util/Set;Ljava/util/Set;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForDescription (Lorg/jetbrains/dokka/model/Documentable;)Ljava/util/List;
protected fun contentForEntries (Ljava/util/List;Ljava/util/Set;Ljava/util/Set;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForFunction (Lorg/jetbrains/dokka/model/DFunction;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForMember (Lorg/jetbrains/dokka/model/Documentable;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForMembers (Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForModule (Lorg/jetbrains/dokka/model/DModule;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForPackage (Lorg/jetbrains/dokka/model/DPackage;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForProperty (Lorg/jetbrains/dokka/model/DProperty;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForScope (Ljava/util/Set;Ljava/util/Set;Ljava/util/List;Ljava/util/List;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForScope (Lorg/jetbrains/dokka/model/WithScope;Lorg/jetbrains/dokka/links/DRI;Ljava/util/Set;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForScopes (Ljava/util/List;Ljava/util/Set;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForScope (Lorg/jetbrains/dokka/model/WithScope;Lorg/jetbrains/dokka/links/DRI;Ljava/util/Set;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentGroup;
public static synthetic fun contentForScope$default (Lorg/jetbrains/dokka/base/translators/documentables/DefaultPageCreator;Lorg/jetbrains/dokka/model/WithScope;Lorg/jetbrains/dokka/links/DRI;Ljava/util/Set;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun contentForScopes (Ljava/util/List;Ljava/util/Set;Ljava/util/List;)Lorg/jetbrains/dokka/pages/ContentGroup;
public static synthetic fun contentForScopes$default (Lorg/jetbrains/dokka/base/translators/documentables/DefaultPageCreator;Ljava/util/List;Ljava/util/Set;Ljava/util/List;ILjava/lang/Object;)Lorg/jetbrains/dokka/pages/ContentGroup;
protected fun divergentBlock (Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/lang/String;Ljava/util/Collection;Lorg/jetbrains/dokka/pages/ContentKind;Lorg/jetbrains/dokka/model/properties/PropertyContainer;)V
public static synthetic fun divergentBlock$default (Lorg/jetbrains/dokka/base/translators/documentables/DefaultPageCreator;Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder$DocumentableContentBuilder;Ljava/lang/String;Ljava/util/Collection;Lorg/jetbrains/dokka/pages/ContentKind;Lorg/jetbrains/dokka/model/properties/PropertyContainer;ILjava/lang/Object;)V
protected fun getContentBuilder ()Lorg/jetbrains/dokka/base/translators/documentables/PageContentBuilder;
Expand Down
5 changes: 1 addition & 4 deletions plugins/base/src/main/kotlin/DokkaBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class DokkaBase : DokkaPlugin() {
val outputWriter by extensionPoint<OutputWriter>()
val htmlPreprocessors by extensionPoint<PageTransformer>()
val kotlinAnalysis by extensionPoint<KotlinAnalysis>()
@Deprecated("It is not used anymore")
val tabSortingStrategy by extensionPoint<TabSortingStrategy>()
val immediateHtmlCommandConsumer by extensionPoint<ImmediateHtmlCommandConsumer>()
val externalDocumentablesProvider by extensionPoint<ExternalDocumentablesProvider>()
Expand Down Expand Up @@ -182,10 +183,6 @@ class DokkaBase : DokkaPlugin() {
}
}

val defaultTabSortingStrategy by extending {
tabSortingStrategy with DefaultTabSortingStrategy()
}

val htmlRenderer by extending {
CoreExtensions.renderer providing ::HtmlRenderer
}
Expand Down

This file was deleted.

Loading

0 comments on commit 1040288

Please sign in to comment.