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
Fix reversed ordering of enum entries #2469
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,7 +216,7 @@ class DocumentableVisibilityFilterTransformer(val context: DokkaContext) : PreMe | |
} | ||
|
||
private fun filterEnumEntries(entries: List<DEnumEntry>, filteredPlatforms: Set<DokkaSourceSet>): Pair<Boolean, List<DEnumEntry>> = | ||
entries.foldRight(Pair(false, emptyList())) { entry, acc -> | ||
entries.fold(Pair(false, emptyList())) { acc, entry -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This caused elements to be reversed |
||
val intersection = filteredPlatforms.intersect(entry.sourceSets) | ||
if (intersection.isEmpty()) Pair(true, acc.second) | ||
else { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am not sure we should have a different sorting for enum entries in a tree. We can discuss it on our meetings.
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.
Do you want to discuss it first or can I merge the PR already? :) I'll revert it if we decide it should be alphabetical
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.
up to you)
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'll merge it then because another PR (related to spaces) depends on it, I'll need to rebase on these changes before merging
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.
Hello. As the person who reported #2466, I wanted to make a case that enum members should always be listed in the order they appear in the source code, not alphabetical order. The order of enumerated type members often reflects important semantics about the problem domain. In my case, it is important to me that the planets are listed in order of distance from the Sun. Sorting them by their English names will confuse/distract people reading my documentation. In a sense, it makes their English names more important than their natural order, which is unhelpful for non-English speakers. I would also suggest that any developer who wants their enumerated types in alphabetical order can simply write their code with that order. If there is no consensus about this, I would hope I could at least have some kind of
@preserveOrder
tag I can put in the comments above my enum class. Thank you for your consideration in this.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, I actually totally agree with everything up above and wanted to convey the same message.
Another point is that if you have a bunch of classes up in the air - it's unclear how to sort them in a single list other than alphabetically. This is not the case with enum entries though, which have strict linear ordering. Some people even write code around
ordinal
property (which is bad, but still). So it only makes sense to preserve the ordering.