airbnb / Showkase

🔦 Showkase is an annotation-processor based Android library that helps you organize, discover, search and visualize Jetpack Compose UI elements
https://medium.com/airbnb-engineering/introducing-showkase-a-library-to-organize-discover-and-visualize-your-jetpack-compose-elements-d5c34ef01095
Apache License 2.0
2.11k stars 107 forks source link

Fix indentation in generated browser code #258

Closed wang-li closed 2 years ago

wang-li commented 2 years ago

Overview

In this PR, I fixed the indentations in ShowkaseBrowserWriter so that it does not shift the code by a double indentation every time it generates code for a preview parameter provider.

The results were asserted by looking at the generated files (the fixed indent is at line 101 in the following screenshots):

Before After

I also added the extension withDoubleIndent { } so that the indentations can safely unindent after the relevant block. This extension is based on the existing withIndent { } extension from Kotlin poet.

Finally, I wanted to add a unit test to avoid this issue to resurface but I struggled to understand how the unit tests in showkase-processor-testing work... But I'm open for some guidance! 😄

This fixes https://github.com/airbnb/Showkase/issues/257

wang-li commented 2 years ago

Thank you very much for the instructions @vinaygaba! 🙏 I updated the commit, adding the relevant test and removing the previous unit tests changes in the showkase-browser-testing to reduce the noise around this PR 😉

wang-li commented 2 years ago

Thank you for taking the time to review my PR 🙏

wang-li commented 2 years ago

Hey @vinaygaba 👋 Would it be possible to get a new release in order to benefit this fix through a gradle dependency? 🙏

vinaygaba commented 2 years ago

@wang-li I was hoping to get one more change in before I do the next release. You can expect it tomorrow

hhalse commented 1 year ago

Hey @vinaygaba 👋 Will there be a new release for this fix?