From b5c1481d5a39e007e5c0f07b53ced09e8e669a09 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 22 Apr 2024 14:51:54 +0200 Subject: [PATCH 1/2] Link to RSPEC --- src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt b/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt index dd38b4d..081c767 100644 --- a/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt +++ b/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt @@ -777,7 +777,11 @@ class RecipeMarkdownGenerator : Runnable { writeln("### Tags") newLine() for (tag in recipeDescriptor.tags) { - writeln("* $tag") + if (tag.lowercase().startsWith("rspec-")) { + writeln("* [$tag](https://sonarsource.github.io/rspec/#/rspec/S${tag.substring(6)})") + } else { + writeln("* $tag") + } } newLine() } From f7ec85132d6c6cd131081a13e905f9d204f4e23a Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Mon, 22 Apr 2024 15:01:43 +0200 Subject: [PATCH 2/2] Handle optional `S` --- .../kotlin/org/openrewrite/RecipeMarkdownGenerator.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt b/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt index 081c767..8afa303 100644 --- a/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt +++ b/src/main/kotlin/org/openrewrite/RecipeMarkdownGenerator.kt @@ -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 @@ -777,7 +780,9 @@ class RecipeMarkdownGenerator : Runnable { writeln("### Tags") newLine() for (tag in recipeDescriptor.tags) { - if (tag.lowercase().startsWith("rspec-")) { + 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") @@ -841,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