-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render member extensions correctly #3374
Conversation
After the grooming: I do not know if this function will be useful fun <T> T.isTopLevelExtension() where T : Documentable, T : Callable = receiver != null && dri.classNames.isNullOrBlank() |
df0749a
to
8fafb82
Compare
For now, I deprecated function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done with the tests! And it's nice to see that typesBlock
was extracted from divergentBlock
, I think it makes it much easier to understand what's going on in different tabs 👍
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Outdated
Show resolved
Hide resolved
setOf(element.dri), | ||
element.sourceSets.toSet(), | ||
extra = PropertyContainer.withAll( | ||
SymbolAnchorHint(element.name ?: "", rowKind) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this anchor get lost accidentally? Don't see it in the new code
Dokka's extras are tricky here, they get propagated down, so maybe it's all good and this anchor came down from row's extras and exists in the output, just not in the code. Although up above it uses group.name
, whereas before it used just name
from the function parameters, so not sure how it works now
Would you be able to compare the HTML output of before and after this change? To see if the layout in general (divs/spans) and the styles/css classes are the same, and it's only the content that changed in specific scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's passed above in https://github.com/Kotlin/dokka/pull/3374/files#diff-1b193984c3c1257fc41e713fa16d6decba9266439b235ac447e1400367951f21R810
group.name
is the same as element.name
as group is grouped by name
:)
So, element
is function/property object and group
is a group of functions/properties with the same name - so no changes here
I will recheck if it make any difference in the output
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Outdated
Show resolved
Hide resolved
@@ -24,4 +24,8 @@ public fun DTypeParameter.filter(filteredSet: Set<DokkaSourceSet>): DTypeParamet | |||
) | |||
} | |||
|
|||
@Deprecated( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make it in #3365 to have one decision for such a function. Moreover, it was introduced recently here #2764 (comment)
not sure, that we need to rely on it
What is you concern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will revert changes here. My main concern is that the body of this function is rather straightforward code to write, but having such as an extension on Documentable
feels strange and not obvious + we don't have a use-case for it and no-one asked for it. Not sure, that we need to make such functions our ABI.
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Outdated
Show resolved
Hide resolved
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Outdated
Show resolved
Hide resolved
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Outdated
Show resolved
Hide resolved
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Show resolved
Hide resolved
* cleanup logic a bit * add documentation for unclear things * revert some ABI changes
8fafb82
to
2bcd3da
Compare
...ase/src/main/kotlin/org/jetbrains/dokka/base/translators/documentables/DefaultPageCreator.kt
Show resolved
Hide resolved
* Add a lot of tests for extensions rendering in different cases * Add documentation for unclear things
Fixes #3187
Context
During building Classlike page, separate tabs for
members
andmembers+extensions
are configured insidedivergentBlock
. Functions/Properties are divided in members and extensions by callingDocumentable.isExtension
(returns if function/property is extension or not based on existence of receiver).Problem
Kotlin also has member extensions, which should be shown on
members
page, butDocumentable.isExtension
for them returnstrue
because, you know, they are extensions.To better illustrate the problem, here is a sample code:
Expected behaviour
Functions 1, 2, 3 should be shown on
members
tab, and onmembers+extensions
additionally shown 4 and 5Current behaviour
Only function 1 is shown on
members
tab, and onmembers+extensions
additionally shown 1, 2, 3, 4, 5.Code problem
DocumentableContentBuilder.divergentBlock
only acceptsList<Documentable>
(whereDocumentable
could be function, property or type), and having only this we can't distinguish, is this function/property ismember extension in type Receiver
or it isexternal extension with receiver of type Receiver
.But we have this information upper in chain:
CallableExtensions
extrareceiver != null
the same way as inDocumentable.isExtension
. We don't really render top-level declarations and top-level extensions differently in HTML or other formats, but we have tests for it :)Another minor problem(inconvenience) that now processing types, functions and properties is done via single function (
DocumentableContentBuilder.divergentBlock
), and so it already has multiple checks, if we are processing different kinds of documentables and change behaviour accordinglySolution
Questions
Documentable.isExtension
in core? (it was used only indokka-base
sDefaultPageCreator.kt
)DefaultPageCreator
ABI? Now half of members thereprotected open
and halfprivate
. In our codebase the only usage is inkotlin-as-java
to override 1 function.On GitHub there is also only one usage of it in island-time - only
contentForModule
is overridden there (the only change is headers of table - looks like it is to fix rendering of packages in GHM format)