Skip to content

Commit cdd44ee

Browse files
committed
Add information about the language a recipe is written in
Fixes: #260
1 parent 3008e84 commit cdd44ee

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ class RecipeMarkdownWriter(
2828
return recipeSource.toString().startsWith("typescript-search://")
2929
}
3030

31+
/**
32+
* Determines the implementation language of a recipe based on its source URI.
33+
* - TypeScript recipes have URIs starting with "typescript-search://"
34+
* - YAML (declarative) recipes have URIs ending with ".yml"
35+
* - All other recipes are assumed to be Java
36+
*/
37+
private fun getRecipeLanguage(recipeDescriptor: RecipeDescriptor): String {
38+
val recipeSource = recipeToSource[recipeDescriptor.name]?.toString() ?: return "Java"
39+
return when {
40+
recipeSource.startsWith("typescript-search://") -> "TypeScript"
41+
recipeSource.endsWith(".yml") -> "YAML"
42+
else -> "Java"
43+
}
44+
}
45+
3146
fun writeRecipe(
3247
recipeDescriptor: RecipeDescriptor,
3348
outputPath: Path,
@@ -127,12 +142,15 @@ import TabItem from '@theme/TabItem';
127142
}
128143

129144
private fun BufferedWriter.writeSourceLinks(recipeDescriptor: RecipeDescriptor, origin: RecipeOrigin) {
145+
val recipeLanguage = getRecipeLanguage(recipeDescriptor)
130146
if (origin.license == Licenses.Proprietary) {
131147
//language=markdown
132148
writeln(
133149
"""
134150
## Recipe source
135151
152+
**Language**: $recipeLanguage
153+
136154
This recipe is only available to users of [Moderne](https://docs.moderne.io/).
137155
138156
""".trimIndent()
@@ -145,6 +163,8 @@ import TabItem from '@theme/TabItem';
145163
"""
146164
## Recipe source
147165
166+
**Language**: $recipeLanguage
167+
148168
[GitHub](${origin.githubUrl(recipeDescriptor.name, recipeSource)}),
149169
[Issue Tracker](${origin.issueTrackerUrl()}),
150170
[Maven Central](https://central.sonatype.com/artifact/${origin.groupId}/${origin.artifactId}/)

0 commit comments

Comments
 (0)