Skip to content

Configure writerside to include tables #324

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

Merged
merged 47 commits into from
Apr 26, 2023
Merged

Conversation

koperagen
Copy link
Collaborator

@koperagen koperagen commented Mar 24, 2023

We now have a custom component for embedding tables. This feature is available on a custom branch of writerside, but still should reach our CI/CD before KotlinConf #233
image

Still need to figure out some details like displaying before / after, schema and maybe giving some visual clues to highlight what the operation does.

@koperagen koperagen changed the title Configure writerside to include tables #233 Configure writerside to include tables Mar 24, 2023
@koperagen koperagen force-pushed the documentation-tables branch 2 times, most recently from 8ace975 to 61a56ab Compare April 6, 2023 16:04
@koperagen koperagen temporarily deployed to github-pages April 6, 2023 19:03 — with GitHub Actions Inactive
@koperagen koperagen temporarily deployed to github-pages April 6, 2023 19:07 — with GitHub Actions Inactive
@koperagen koperagen force-pushed the documentation-tables branch 4 times, most recently from 95dade0 to e04e0cd Compare April 6, 2023 19:50
@koperagen koperagen temporarily deployed to github-pages April 6, 2023 19:52 — with GitHub Actions Inactive
@koperagen koperagen temporarily deployed to github-pages April 10, 2023 20:12 — with GitHub Actions Inactive
@koperagen koperagen force-pushed the documentation-tables branch from 467cff3 to d1e4f88 Compare April 11, 2023 11:34
@koperagen koperagen temporarily deployed to github-pages April 11, 2023 13:32 — with GitHub Actions Inactive
@koperagen koperagen force-pushed the documentation-tables branch from d6ff368 to ccc19e3 Compare April 11, 2023 14:19
@koperagen koperagen temporarily deployed to github-pages April 11, 2023 14:22 — with GitHub Actions Inactive
@koperagen koperagen temporarily deployed to github-pages April 11, 2023 14:30 — with GitHub Actions Inactive
@koperagen koperagen force-pushed the documentation-tables branch from ccc19e3 to 014fa67 Compare April 11, 2023 14:34
@koperagen koperagen temporarily deployed to github-pages April 11, 2023 14:36 — with GitHub Actions Inactive
@koperagen koperagen temporarily deployed to github-pages April 12, 2023 15:18 — with GitHub Actions Inactive
@koperagen koperagen marked this pull request as ready for review April 13, 2023 17:35
@koperagen koperagen force-pushed the documentation-tables branch from c92dc2b to 0fd4d4f Compare April 13, 2023 17:41
@koperagen
Copy link
Collaborator Author

koperagen commented Apr 13, 2023

I'll add documentation later as the process of adding tables to documentation should be refined. But the general idea is that you annotate a function and the compiler plugin adds "also { }" call after each "interesting" expression. That enables us to process samples (compose HTML outputs) without manually rewriting all samples using samplesTest and copySamplesOutputs. Created HTML are copied to docs/snippets, where writerside picks them up and embeds as iframes.
It does not affect a normal test task.
If a sample needs fine tuning, i think most straightforward way is to disable compiler transformation and create HTML output manually.

@Jolanrensen Jolanrensen self-requested a review April 17, 2023 10:20
Copy link
Collaborator

@Jolanrensen Jolanrensen left a comment

Choose a reason for hiding this comment

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

Very cool! Makes it easy to see intermediate dataframe states in documentation. However, we do need to consider the extra maintainability of another compiler plugin. Especially when we need to move to k2 eventually. It's difficult to understand most of the testing of the plugin as well as the code itself. But that's the case with most compiler plugins. That said, I do think it's worth it :)

@@ -45,6 +46,7 @@ df.convert { name.firstName and name.lastName }.to { it.length() }
df.convert { weight }.toFloat()
```

<dataFrame src="org.jetbrains.kotlinx.dataframe.samples.api.Modify.convertTo.html"/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Which of the convert functions is rendered here? or all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

0 -> {
val table = convertToHTML(expression.df)
val description = table.copy(
body = """
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here with @language

@koperagen koperagen requested a review from Jolanrensen April 26, 2023 12:29
@@ -32,3 +33,4 @@ pluginManagement {
}
}


Copy link
Collaborator

Choose a reason for hiding this comment

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

another newline? haha

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

return data
}

var action: PluginCallback = PluginCallback { source, name, df, id, receiverId, containingClassFqName, containingFunName, statementIndex ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better :D

}
}
val alsoLambdaExpression = IrFunctionExpressionImpl(
-1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

missed some named arguments. A good linter could probably help with these... We really need to fix that soon :)

Copy link
Collaborator Author

@koperagen koperagen Apr 26, 2023

Choose a reason for hiding this comment

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

I don't think it's for a linter to decide :D I would add them, but generally, in my opinion, it's up for a debate at review

type = pluginContext.irBuiltIns.functionN(2)
.typeWith(listOf(expression.type, pluginContext.irBuiltIns.unitType)),
alsoLambda,
IrStatementOrigin.LAMBDA
Copy link
Collaborator

Choose a reason for hiding this comment

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

same with trailing comma's. I think currently I'm the one adding them and you're the one leaving them out haha.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I believe this constructor is quite a stable API and won't require changing parameters order :p

Copy link
Collaborator

Choose a reason for hiding this comment

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

You never know, especially with k2 around the corner. We had those incompatibility issues with korro because in 1.8.20 they suddenly added another parameter. Naming them at least helps a bit :) (Also for reviewing)

@koperagen koperagen merged commit 6208e47 into master Apr 26, 2023
@koperagen
Copy link
Collaborator Author

@Jolanrensen Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants