Skip to content

Commit

Permalink
Do not show null as example value
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 13, 2023
1 parent c65ebf6 commit 3ab4c64
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ class RecipeMarkdownGenerator : Runnable {
@Suppress("SENSELESS_COMPARISON")
if (descriptor != null && descriptor.description != null) {
appendLine()
if (descriptor.description.contains("\n") || descriptor.description.contains("_")){
if (descriptor.description.contains("\n") || descriptor.description.contains("_")) {
appendLine(descriptor.description)
} else {
appendLine("_${descriptor.description}_")
Expand Down Expand Up @@ -813,7 +813,7 @@ class RecipeMarkdownGenerator : Runnable {
// Options
if (recipeDescriptor.options.isNotEmpty()) {
writeln(
"""
"""
## Options
| Type | Name | Description | Example |
Expand Down Expand Up @@ -843,8 +843,8 @@ class RecipeMarkdownGenerator : Runnable {
}
}
writeln(
"""
| `${option.type}` | ${option.name} | $description | `${option.example}` |
"""
| `${option.type}` | ${option.name} | $description | `${option.example ?: ""}` |
""".trimIndent()
)
}
Expand Down Expand Up @@ -874,19 +874,23 @@ class RecipeMarkdownGenerator : Runnable {
}

for (dataTable in filteredDataTables) {
writeln("""
writeln(
"""
### ${dataTable.displayName}
_${dataTable.description}_
| Column Name | Description |
| ----------- | ----------- |
""".trimIndent())
""".trimIndent()
)

for (column in dataTable.columns) {
writeln("""
writeln(
"""
| ${column.displayName} | ${column.description} |
""".trimIndent())
""".trimIndent()
)
}

newLine()
Expand Down Expand Up @@ -1001,7 +1005,7 @@ class RecipeMarkdownGenerator : Runnable {

writeln("{% code %}")
writeln(
"""
"""
|```diff
|${diff}```
""".trimMargin()
Expand Down Expand Up @@ -1178,14 +1182,15 @@ class RecipeMarkdownGenerator : Runnable {
if (recipeDescriptor.contributors.isNotEmpty()) {
newLine()
writeln("## Contributors")
writeln(recipeDescriptor.contributors.stream()
.map { contributor: Contributor ->
if (contributor.email.contains("noreply")) {
contributor.name
} else {
"[" + contributor.name + "](mailto:" + contributor.email + ")"
}
}.collect(Collectors.joining(", "))
writeln(
recipeDescriptor.contributors.stream()
.map { contributor: Contributor ->
if (contributor.email.contains("noreply")) {
contributor.name
} else {
"[" + contributor.name + "](mailto:" + contributor.email + ")"
}
}.collect(Collectors.joining(", "))
)
}
}
Expand All @@ -1207,8 +1212,8 @@ class RecipeMarkdownGenerator : Runnable {
val revisedLines = revised.lines()

diffContent.append("@@ -${delta.source.position + 1},${delta.source.size()} ")
.append("+${delta.target.position + 1},${delta.target.size()} @@")
.append("\n")
.append("+${delta.target.position + 1},${delta.target.size()} @@")
.append("\n")

// print shared context
val startIndex = maxOf(0, delta.source.position - contextLinesBefore)
Expand All @@ -1218,12 +1223,14 @@ class RecipeMarkdownGenerator : Runnable {
}

for (i in delta.source.position until delta.source.position + delta.source.size()) {
val trimmedLine = if (originalLines[i].startsWith(" ")) originalLines[i].replaceFirst(" ", "") else originalLines[i]
val trimmedLine =
if (originalLines[i].startsWith(" ")) originalLines[i].replaceFirst(" ", "") else originalLines[i]
diffContent.append("-").append(trimmedLine).append("\n")
}

for (i in delta.target.position until delta.target.position + delta.target.size()) {
val trimmedLine = if (revisedLines[i].startsWith(" ")) revisedLines[i].replaceFirst(" ", "") else revisedLines[i]
val trimmedLine =
if (revisedLines[i].startsWith(" ")) revisedLines[i].replaceFirst(" ", "") else revisedLines[i]
diffContent.append("+").append(trimmedLine).append("\n")
}

Expand Down

0 comments on commit 3ab4c64

Please sign in to comment.