Skip to content

Commit

Permalink
Update name of arg based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaygaba committed Dec 15, 2024
1 parent eea6124 commit 0588915
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ class ShowkaseProcessorTest : BaseProcessorTest() {
@Test
fun `composable functions with preview annotation are skipped`() {
val options = mutableMapOf<String, String>()
options["skipFunctionsWithPreviewAnnotation"] = "true"
options["requireShowkaseComposableAnnotation"] = "true"
compileInputsAndVerifyOutputs(options = options)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ public fun TestShowkaseComposable2() {
public fun TestPreviewComposable3() {

}

@Preview(name = "name4", group = "group4")
@ShowkaseComposable(name = "name4", group = "group4")
@Composable
public fun TestShowkaseComposable4() {

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,22 @@ public class
public
fun ShowkaseProcessorTestcomposablefunctionswithpreviewannotationareskippedinputTestShowkaseComposable2group2name2() {
}

@ShowkaseCodegenMetadata(
showkaseName = "name4",
showkaseGroup = "group4",
packageName =
"ShowkaseProcessorTest.composable_functions_with_preview_annotation_are_skipped.input",
packageSimpleName = "input",
showkaseElementName = "TestShowkaseComposable4",
insideObject = false,
insideWrapperClass = false,
showkaseKDoc = "",
generatedPropertyName = "TestShowkaseComposable4group4name4",
showkaseMetadataType = "COMPONENT",
isDefaultStyle = false,
)
public
fun ShowkaseProcessorTestcomposablefunctionswithpreviewannotationareskippedinputTestShowkaseComposable4group4name4() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This is an auto-generated file. Please do not edit/modify this file.
package ShowkaseProcessorTest.composable_functions_with_preview_annotation_are_skipped.input

import androidx.compose.runtime.Composable
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent

public val TestShowkaseComposable4group4name4: ShowkaseBrowserComponent = ShowkaseBrowserComponent(
group = "group4",
componentName = "name4",
componentKDoc = "",
componentKey =
"""ShowkaseProcessorTest.composable_functions_with_preview_annotation_are_skipped.input_TestShowkaseComposable4_null_group4_name4_0_null""",
isDefaultStyle = false,
component = @Composable { TestShowkaseComposable4() }
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.airbnb.android.showkase.models.ShowkaseProvider
import kotlin.collections.List

@ShowkaseRootCodegen(
numComposablesWithoutPreviewParameter = 2,
numComposablesWithoutPreviewParameter = 3,
numComposablesWithPreviewParameter = 0,
numColors = 0,
numTypography = 0,
Expand All @@ -20,6 +20,7 @@ public class TestShowkaseRootCodegen : ShowkaseProvider {
return listOf<ShowkaseBrowserComponent>(
TestShowkaseComposable1group1name1,
TestShowkaseComposable2group2name2,
TestShowkaseComposable4group4name4,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ShowkaseProcessor @JvmOverloads constructor(
}
override fun getSupportedOptions() = mutableSetOf(
"skipPrivatePreviews",
"skipFunctionsWithPreviewAnnotation",
"requireShowkaseComposableAnnotation",
"multiPreviewType"
)

Expand Down Expand Up @@ -132,9 +132,10 @@ class ShowkaseProcessor @JvmOverloads constructor(

private fun processPreviewAnnotation(roundEnvironment: XRoundEnv): Set<ShowkaseMetadata.Component> {
val skipPrivatePreviews = environment.options["skipPrivatePreviews"] == "true"
val skipFunctionsWithPreviewAnnotation = environment.options["skipFunctionsWithPreviewAnnotation"] == "true"
val requireShowkaseComposableAnnotation =
environment.options["requireShowkaseComposableAnnotation"] == "true"

if (skipFunctionsWithPreviewAnnotation) return emptySet()
if (requireShowkaseComposableAnnotation) return emptySet()

return roundEnvironment.getElementsAnnotatedWith(PREVIEW_CLASS_NAME)
.mapNotNull { element ->
Expand Down

0 comments on commit 0588915

Please sign in to comment.