Skip to content

Commit aa8b452

Browse files
committed
Show more recipe details
1 parent 4d31e75 commit aa8b452

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/main/kotlin/org/openrewrite/RecipeDescriptorExtensions.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private fun escape(string: String): String = string
2222
.replace(">", ">")
2323
.replace("\"", """)
2424

25-
fun RecipeDescriptor.asYaml(): String {
25+
fun RecipeDescriptor.asYaml(hideOptions: Boolean): String {
2626
val s = StringBuilder()
2727
s.appendLine("""
2828
---
@@ -52,13 +52,13 @@ description: |
5252
}
5353

5454
s.append(" - ${subRecipe.name}")
55-
if (subRecipe.options.isEmpty() || subRecipe.options.all { it.value == null }) {
55+
if (subRecipe.options.isEmpty() || subRecipe.options.all { it.value == null } || hideOptions) {
5656
s.appendLine()
5757
} else {
5858
s.appendLine(":")
59-
}
60-
for (subOption in subRecipe.options) {
61-
s.append(subOption.asYaml(3))
59+
for (subOption in subRecipe.options) {
60+
s.append(subOption.asYaml(3))
61+
}
6262
}
6363
}
6464
}

src/main/kotlin/org/openrewrite/RecipeMarkdownWriter.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import java.nio.file.Files
1010
import java.nio.file.Path
1111
import java.nio.file.StandardOpenOption
1212
import java.util.regex.Pattern
13-
import java.util.stream.Collectors.joining
1413

1514
class RecipeMarkdownWriter(val recipeContainedBy: MutableMap<String, MutableSet<RecipeDescriptor>>) {
1615

@@ -69,7 +68,7 @@ import TabItem from '@theme/TabItem';
6968

7069
writeSourceLinks(recipeDescriptor, origin)
7170
writeOptions(recipeDescriptor)
72-
writeDefinition(recipeDescriptor, origin)
71+
writeDefinition(recipeDescriptor, origin.license == Licenses.Proprietary)
7372
writeUsedBy(recipeContainedBy[recipeDescriptor.name])
7473
writeExamples(recipeDescriptor)
7574
writeUsage(recipeDescriptor, origin)
@@ -531,8 +530,8 @@ import TabItem from '@theme/TabItem';
531530
}
532531
}
533532

534-
private fun BufferedWriter.writeDefinition(recipeDescriptor: RecipeDescriptor, origin: RecipeOrigin) {
535-
if (recipeDescriptor.recipeList.isNotEmpty() && origin.license != Licenses.Proprietary) {
533+
private fun BufferedWriter.writeDefinition(recipeDescriptor: RecipeDescriptor, hideOptions: Boolean) {
534+
if (recipeDescriptor.recipeList.isNotEmpty()) {
536535
//language=markdown
537536
writeln(
538537
"""
@@ -574,7 +573,7 @@ import TabItem from '@theme/TabItem';
574573
)
575574
}
576575

577-
if (recipe.options.isNotEmpty()) {
576+
if (recipe.options.isNotEmpty() && !hideOptions) {
578577
for (option in recipe.options) {
579578
if (option.value != null) {
580579
val formattedOptionString = printValue(option.value!!)
@@ -597,7 +596,7 @@ import TabItem from '@theme/TabItem';
597596
```yaml
598597
""".trimIndent()
599598
)
600-
writeln(recipeDescriptor.asYaml())
599+
writeln(recipeDescriptor.asYaml(hideOptions))
601600
//language=markdown
602601
writeln(
603602
"""

0 commit comments

Comments
 (0)