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

Added ability to skip @Preview functions #401

Merged
merged 7 commits into from
Dec 15, 2024

Conversation

vinaygaba
Copy link
Collaborator

@vinaygaba vinaygaba commented Dec 11, 2024

This PR adds the ability to skip @Preview composable from being picked up by Showkase. I had previously added the ability to skip an individual composable using the skip property that's added to the ShowkaseComposable annotation.

However, this config option allows one to skip all @Preview annotation with a single line. While Showkase picking up functions annotated with @Preview is an important feature that makes the library more useful, there might be cases where you might want to enforce usage of the ShowkaseComposable annotation instead as that's a more explicit way to integrate with Showkase. In order to use this feature, you can use the following snippet in your gradle file.

If you use KSP:

ksp {
 arg("requireShowkaseComposableAnnotation", "true")
}

If you use KAPT:

kapt {
 arguments {
  arg("requireShowkaseComposableAnnotation", "true")
 }
}

This PR also contains upgrades to Detekt + Gradle and the fixes that detekt required as a result. Would've been ideal to split this in separate PR's but since I didn't anticipate needing these many changes and I was further along, I decided to just continue adding it to this PR.

@elihart @allenchen1154

@vinaygaba vinaygaba marked this pull request as ready for review December 11, 2024 11:38
@@ -78,7 +78,7 @@ class ShowkaseProcessor @JvmOverloads constructor(
?.toSet()?.let { set.addAll(it) }
return set
}
override fun getSupportedOptions() = mutableSetOf("skipPrivatePreviews", "multiPreviewType")
override fun getSupportedOptions() = mutableSetOf("skipPrivatePreviews", "skipFunctionsWithPreviewAnnotation", "multiPreviewType")
Copy link
Collaborator Author

@vinaygaba vinaygaba Dec 11, 2024

Choose a reason for hiding this comment

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

Open to having a name other than skipFunctionsWithPreviewAnnotation 🫤 Couldn't think of anything better and not a huge fan of what I ended up using

Copy link
Contributor

@elihart elihart left a comment

Choose a reason for hiding this comment

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

Thanks a lot for adding this!

override fun getSupportedOptions() = mutableSetOf("skipPrivatePreviews", "multiPreviewType")
override fun getSupportedOptions() = mutableSetOf(
"skipPrivatePreviews",
"skipFunctionsWithPreviewAnnotation",
Copy link
Contributor

Choose a reason for hiding this comment

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

might consider a more explicit name, as this won't skip all functions with preview annotations (ie, it keeps the ones with showkase annotation)

Suggested change
"skipFunctionsWithPreviewAnnotation",
"skipPreviewFunctionsWithoutShowkaseAnnotation",

or

Suggested change
"skipFunctionsWithPreviewAnnotation",
"requireShowkaseAnnotation",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this makes sense, thanks for the tip!

@vinaygaba vinaygaba merged commit 30137ac into master Dec 15, 2024
4 checks passed
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