Skip to content

Commit 14e51b8

Browse files
committed
Changes based on Tim's suggestions
1 parent cdd44ee commit 14e51b8

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

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

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ 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-
4631
fun writeRecipe(
4732
recipeDescriptor: RecipeDescriptor,
4833
outputPath: Path,
@@ -142,30 +127,26 @@ import TabItem from '@theme/TabItem';
142127
}
143128

144129
private fun BufferedWriter.writeSourceLinks(recipeDescriptor: RecipeDescriptor, origin: RecipeOrigin) {
145-
val recipeLanguage = getRecipeLanguage(recipeDescriptor)
146130
if (origin.license == Licenses.Proprietary) {
147131
//language=markdown
148132
writeln(
149133
"""
150134
## Recipe source
151135
152-
**Language**: $recipeLanguage
153-
154136
This recipe is only available to users of [Moderne](https://docs.moderne.io/).
155137
156138
""".trimIndent()
157139
)
158140
} else {
159141
val recipeSource = recipeToSource[recipeDescriptor.name]
160142
requireNotNull(recipeSource) { "Could not find source URI for recipe ${recipeDescriptor.name}" }
143+
val recipeSourceFileName = recipeSource.toString().substringAfterLast('/')
161144
//language=markdown
162145
writeln(
163146
"""
164147
## Recipe source
165148
166-
**Language**: $recipeLanguage
167-
168-
[GitHub](${origin.githubUrl(recipeDescriptor.name, recipeSource)}),
149+
[GitHub: $recipeSourceFileName](${origin.githubUrl(recipeDescriptor.name, recipeSource)}),
169150
[Issue Tracker](${origin.issueTrackerUrl()}),
170151
[Maven Central](https://central.sonatype.com/artifact/${origin.groupId}/${origin.artifactId}/)
171152
""".trimIndent()

0 commit comments

Comments
 (0)