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.08k stars 106 forks source link

Generate code to have an API that provides module level metadata of Showkase elements #392

Open vinaygaba opened 1 month ago

vinaygaba commented 1 month ago

This PR adds a new public API that generates metadata about the Showkase elements on a per module basis. This essentially results in a new API being exposes which gives you access to a Showkase.getModuleMetadata() method in every module where Showkase is configured to run.

The reason this is useful is so that this API can be leveraged to define custom tooling and behavior, such as generating a Paparazzi test in each module separately (as opposed to doing it in just the root module with all the previews aggregated). This allows the tests to be better parallelized and even avoided if the module did not have changes.

With this change, a new API is available for you to get access to all the Showkase elements in a given module. Here's what it looks like at the call site -

Showkase.getModuleMetadata()

Addresses: https://github.com/airbnb/Showkase/issues/299 and #379

@elihart @airbnb/showkase-maintainers

vinaygaba commented 1 month ago

@elihart I'll do the test update once we agree on the API direction. Those just need to be regenerated and I'm happy to add them upfront if that helps wrap your head around the changes.

Does anything need to be added to the test codegen to take advantage of this, or will per module tests just work once this is set up?

This is meant to be done in a follow up PR. This change is particular can happen in isolation so figured it makes doing reviews easier.