Skip to content
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

Refactor an internal API system (part 1: new class system & remove all internal properties from DSL) #376

Merged
merged 26 commits into from
Jun 19, 2024

Conversation

AndreiKingsley
Copy link
Collaborator

@AndreiKingsley AndreiKingsley commented Apr 25, 2024

This is the first part of several PRs with internal API redesigns. In this one, I reworked the class system used to build DSLs. The PR is big, but the minimum possible because it changes the root of the system.

What went into this PR

  • A new system of DSL interfaces and classes, most classes/properties are now internal
  • Implementations of these classes for Lets-Plot
    You can build api and lets-plot modules (and test them in a Kotlin Notebook, for example).

What is NOT included in this PR:

  • DatasetHandler is still unchanged
  • echarts module (only some rename was done)
  • Tests
    • I partially changed the tests in the api module to make them consistent with the new API, but a few did not make it yet - I commented them out; the tests in the api module are fully buildable and there're passed
    • In lets-plot the tests are not consistent
      • Statistics needs to be updated as well
  • Documentation

Fixes #163, fixes #378, fixes #379, fixes #380, fixes #381.

@AndreiKingsley AndreiKingsley added this to the Kandy release v0.7.0 milestone May 1, 2024
Copy link
Collaborator

@devcrocod devcrocod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the first part regarding the API

Copy link
Collaborator

@devcrocod devcrocod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is necessary to write KDoc and check the current ones. Also, in abstract classes, you can use protected instead of internal, so that properties will be accessible in subclasses.

@AndreiKingsley
Copy link
Collaborator Author

In most cases, the properties need to be accessible outside of the class so they are made internal (i.e. actually public, but for modules, not to the user - what I called semi-internal)

@AndreiKingsley
Copy link
Collaborator Author

@devcrocod add ColumnsContainer to GroupedDataScope with last commit, check please

include("kandy-util")

include("examples:idea-examples:lets-plot-simple")
include("examples:idea-examples:echarts-simple")
//include("examples:idea-examples:echarts-simple")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to stay with commented subprojects? or better to remove it, or it removed only in this PR for the debug purposes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed in the 4th PR.

* - [y][AreaContext.y] - mapping data on the y-axis.
* - [color][AreaContext.color] - area fill [color][org.jetbrains.kotlinx.kandy.util.color.Color].
* - [position][AreaContext.position] -
* - [ x][AreaHandler.x] - mapping data on the x-axis.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ x]- > [x]?

* - [y][BarContext.y] - mapping data on the y-axis.
* - [color][BarContext.color] - bars [color][org.jetbrains.kotlinx.kandy.util.color.Color].
* - [alpha][BarContext.alpha] - bars opacity.
* - [ x][BarHandler.x] - mapping data on the x-axis.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ x] -> [x]?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and all [ x] inclusions through the whole project

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KDocs works incorrect here without space for some reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also this PR is not about echarts documentation at all, let's discuss it in future.

class LayerCreatorScopeTest {

@Test
fun `test addLayer`() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need here a test with addition of a few layers in the correct order?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests are fixed in the next PR.

import org.jetbrains.kotlinx.kandy.ir.bindings.PositionalMapping

internal fun <T> PlotContext.x(
internal fun <T> MultiLayerPlotBuilder.x(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we rename xy.kt to something else? MultiLayerPlotBuilder XY in naming?

* Adds a [positional setting][PositionalSetting] with the given aes and value.
*
* @param aes the aesthetic attribute (aes) to associate with the positional setting.
* @param value the value of the setting.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest avoiding using value for variable names and parameter names, it's too common and leads to nothing, could you please rename it

Copy link
Collaborator Author

@AndreiKingsley AndreiKingsley Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it's literally "value". What alternative do you suggest? settingValue?

*/
open fun <DomainType, RangeType> addNonPositionalMapping(
aes: Aes,
values: List<DomainType>,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domainTypes instead of values?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? You provide values of DomainType here, not types.

*/
public abstract class CustomPlotBuilder: PlotBuilder {
/**
* Plot builder dataset handler.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to use one-row Kdocs

/** Plot builder features collector. */

Copy link
Collaborator Author

@AndreiKingsley AndreiKingsley Jun 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but I prefer "expanded" ones.

@AndreiKingsley AndreiKingsley merged commit d578e30 into main Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants