Skip to content

Commit

Permalink
Correctly link refaster recipes (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek authored Dec 14, 2023
1 parent dc2ecd2 commit aa04d1a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: build
uses: gradle/gradle-build-action@v2
with:
arguments: ${{ env.GRADLE_SWITCHES }} markdownToHtml
arguments: ${{ env.GRADLE_SWITCHES }} check markdownToHtml

- name: Create index.html
run: cp build/html/SUMMARY_snippet.html build/html/index.html
Expand Down
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ dependencies {
implementation("io.github.java-diff-utils:java-diff-utils:4.11")
runtimeOnly("org.slf4j:slf4j-simple:1.7.30")

testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release")

"recipe"(platform("org.openrewrite:rewrite-bom:$rewriteVersion"))
"recipe"("org.openrewrite:rewrite-core")
"recipe"("org.openrewrite:rewrite-groovy")
Expand Down Expand Up @@ -111,6 +114,10 @@ tasks.named<JavaCompile>("compileJava") {
targetCompatibility = JavaVersion.VERSION_17.toString()
}

tasks.withType<Test> {
useJUnitPlatform()
}

application {
mainClass.set("org.openrewrite.RecipeMarkdownGenerator")
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/org/openrewrite/RecipeOrigin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RecipeOrigin(
fun isFromCoreLibrary() = groupId == "org.openrewrite" && coreLibs.contains(artifactId)

private fun convertNameToJavaPath(recipeName: String): String =
recipeName.replace('.', '/').removeSuffix("Recipe") + ".java"
recipeName.replace('.', '/').replace(Regex("Recipes?\\$?.*"), "") + ".java"

fun githubUrl(recipeName: String, source: URI): String {
val sourceString = source.toString()
Expand Down
21 changes: 21 additions & 0 deletions src/test/kotlin/org/openrewrite/RecipeOriginTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.openrewrite

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import java.net.URI

class RecipeOriginTest {
@Test
fun githubUrl() {
val githubUrl = RecipeOrigin(
"org.openrewrite.recipe", "rewrite-migrate-java", "2.4.2", URI.create("file:///tmp/foo")
).githubUrl(
"org.openrewrite.java.migrate.apache.commons.lang.ApacheCommonsStringUtilsRecipes\$AbbreviateRecipe",
URI("https://github.com")
)
assertEquals(
"https://github.com/openrewrite/rewrite-migrate-java/blob/main/src/main/java/org/openrewrite/java/migrate/apache/commons/lang/ApacheCommonsStringUtils.java",
githubUrl
)
}
}

0 comments on commit aa04d1a

Please sign in to comment.