docs: auto generate list of patches in README.md
(#133)
* feat: auto generate list of patches in `README.md` * sample readme * formatting * add codeblocks * sample readme * run on publish * make workflow commit readme * update readme [skip ci] * update gen [skip ci] * update workflow [skip ci] * add readme to release assets * fix: spacing in title Co-authored-by: Sculas <contact@sculas.xyz> Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
b40ba5cbca
commit
ac1b645ae3
|
@ -15,6 +15,7 @@
|
||||||
"@semantic-release/git",
|
"@semantic-release/git",
|
||||||
{
|
{
|
||||||
"assets": [
|
"assets": [
|
||||||
|
"README.md",
|
||||||
"CHANGELOG.md",
|
"CHANGELOG.md",
|
||||||
"gradle.properties"
|
"gradle.properties"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
Repo for all ReVanced patches
|
# ReVanced Patches
|
||||||
|
🧩 Official patches by ReVanced
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import org.apache.tools.ant.taskdefs.ExecTask
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.7.0"
|
kotlin("jvm") version "1.7.0"
|
||||||
}
|
}
|
||||||
|
@ -49,12 +51,19 @@ tasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
register<JavaExec>("generateReadme") {
|
||||||
|
description = "Generate README.md"
|
||||||
|
dependsOn(build)
|
||||||
|
|
||||||
|
classpath = sourceSets["main"].runtimeClasspath
|
||||||
|
mainClass.set("app.revanced.patches.meta.ReadmeGenerator")
|
||||||
|
}
|
||||||
// Dummy task to fix the Gradle semantic-release plugin.
|
// Dummy task to fix the Gradle semantic-release plugin.
|
||||||
// Remove this if you forked it to support building only.
|
// Remove this if you forked it to support building only.
|
||||||
// Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
|
// Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435
|
||||||
register<DefaultTask>("publish") {
|
register<DefaultTask>("publish") {
|
||||||
group = "publish"
|
group = "publish"
|
||||||
description = "Dummy task"
|
description = "Dummy task"
|
||||||
dependsOn(named("generateDex"))
|
dependsOn(named("generateDex"), named("generateReadme"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
55
src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt
Normal file
55
src/main/kotlin/app/revanced/meta/ReadmeGenerator.kt
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
package app.revanced.patches.meta
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import kotlin.io.writeText
|
||||||
|
import kotlin.collections.first
|
||||||
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.description
|
||||||
|
|
||||||
|
class ReadmeGenerator {
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
//should be moved to a file?
|
||||||
|
val generalReadme =
|
||||||
|
"""
|
||||||
|
# ReVanced Patches
|
||||||
|
🧩 Official patches by ReVanced
|
||||||
|
|
||||||
|
# Patch list
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
val tableHeader =
|
||||||
|
"""
|
||||||
|
| 💊 Patch | 📜 Description | 🎯 Target Package | 🏹 Target Version |
|
||||||
|
|:-----:|:-----------:|:--------------:|:----------------------:|
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
val readmeFile = File("README.md")
|
||||||
|
|
||||||
|
val buildDir = File("build/libs/")
|
||||||
|
val buildJar = buildDir.listFiles().first { it.name.startsWith("revanced-patches-") && it.name.endsWith(".jar") }
|
||||||
|
|
||||||
|
val bundle = JarPatchBundle(buildJar.absolutePath).loadPatches()
|
||||||
|
|
||||||
|
val builder = StringBuilder()
|
||||||
|
|
||||||
|
builder.appendLine(generalReadme)
|
||||||
|
builder.appendLine(tableHeader)
|
||||||
|
|
||||||
|
for (patch in bundle) {
|
||||||
|
val humanName =
|
||||||
|
patch.patchName.split('-').map { it.replaceFirstChar { it.uppercase() } }.joinToString(" ")
|
||||||
|
|
||||||
|
val compatiblePackage = patch.compatiblePackages?.first()
|
||||||
|
val latestVersion = compatiblePackage?.versions?.maxByOrNull { it.replace(".", "").toInt() } ?: "all"
|
||||||
|
|
||||||
|
builder.appendLine("|$humanName|${patch.description}|`${compatiblePackage?.name}`|$latestVersion|")
|
||||||
|
}
|
||||||
|
|
||||||
|
readmeFile.writeText(builder.toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue