Skip to content

Commit

Permalink
Show recipe option example values
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 13, 2023
1 parent 1ae07e9 commit ad0b123
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class RecipeMarkdownGenerator : Runnable {
val recipeOptions = TreeSet<RecipeOption>()
for (recipeOption in recipeDescriptor.options) {
val name = recipeOption.name as String
val ro = RecipeOption(name, recipeOption.type, recipeOption.isRequired)
val ro = RecipeOption(name, recipeOption.type, recipeOption.example, recipeOption.isRequired)
recipeOptions.add(ro)
}

Expand Down Expand Up @@ -610,7 +610,7 @@ class RecipeMarkdownGenerator : Runnable {
} else {
// Some nested recipes have a `github` path which gets converted into `Github` when it should be `GitHub`.
if (displayName == "Github") {
displayName = "GitHub";
displayName = "GitHub"
}

result.appendLine("$indent* [$displayName](reference/recipes/$path/README.md)")
Expand Down Expand Up @@ -816,8 +816,8 @@ class RecipeMarkdownGenerator : Runnable {
"""
## Options
| Type | Name | Description |
| -- | -- | -- |
| Type | Name | Description | Example |
| -- | -- | -- | -- |
""".trimIndent()
)
for (option in recipeDescriptor.options) {
Expand All @@ -837,7 +837,7 @@ class RecipeMarkdownGenerator : Runnable {
}
writeln(
"""
| `${option.type}` | ${option.name} | $description |
| `${option.type}` | ${option.name} | $description | `${option.example}` |
""".trimIndent()
)
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/org/openrewrite/RecipeOption.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ package org.openrewrite
data class RecipeOption(
val name: String,
val type: String,
val example: String?,
val required: Boolean
): Comparable<RecipeOption> {
override fun compareTo(other: RecipeOption): Int {
if (this.name != other.name) return this.name.compareTo(other.name)
if (this.type != other.type) return this.type.compareTo(other.type)
if (this.required && !other.required) return 1
if (!this.required && other.required) return -1

return 0
return compareBy(RecipeOption::name)
.then(compareBy(RecipeOption::type))
.then(compareBy(RecipeOption::example))
.then(compareBy(RecipeOption::required))
.compare(this, other)
}
}

0 comments on commit ad0b123

Please sign in to comment.