Skip to content

Commit

Permalink
RSPEC tag links for context when browsing recipes (#112)
Browse files Browse the repository at this point in the history
* Link to RSPEC

* Handle optional `S`
  • Loading branch information
timtebeek authored Apr 22, 2024
1 parent 50dac39 commit 1b83a91
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ class RecipeMarkdownGenerator : Runnable {
val docLink =
docBaseUrl + recipeDescriptor.name.lowercase(Locale.getDefault()).removePrefix("org.openrewrite.")
.replace('.', '/')
.replace("$", "usd") // needed for refaster templates + gitbook as we have started using $ in our recipe descriptors :(
.replace(
"$",
"usd"
) // needed for refaster templates + gitbook as we have started using $ in our recipe descriptors :(

val recipeSource = recipeDescriptor.source.toString()
var isImperative = true
Expand Down Expand Up @@ -777,7 +780,13 @@ class RecipeMarkdownGenerator : Runnable {
writeln("### Tags")
newLine()
for (tag in recipeDescriptor.tags) {
writeln("* $tag")
if (tag.lowercase().startsWith("rspec-s")) {
writeln("* [$tag](https://sonarsource.github.io/rspec/#/rspec/${tag.substring(6)})")
} else if (tag.lowercase().startsWith("rspec-")) {
writeln("* [$tag](https://sonarsource.github.io/rspec/#/rspec/S${tag.substring(6)})")
} else {
writeln("* $tag")
}
}
newLine()
}
Expand Down Expand Up @@ -837,7 +846,7 @@ class RecipeMarkdownGenerator : Runnable {
"[${match.value}](/reference/method-patterns.md)"
}
// Add valid options to description
if (option.valid?.isNotEmpty()?: false) {
if (option.valid?.isNotEmpty() ?: false) {
description += " Valid options: " + option.valid?.joinToString { "`$it`" }
}
// Preserve table cell formatting for multiline examples
Expand Down

0 comments on commit 1b83a91

Please sign in to comment.