mirror of
https://github.com/revanced/revanced-patches
synced 2025-01-23 10:37:32 +01:00
docs: better structuring (#230)
This commit is contained in:
parent
913866677c
commit
0c579473bb
@ -1,9 +1,7 @@
|
|||||||
# ReVanced Patches
|
# 🧩 ReVanced Patches
|
||||||
|
|
||||||
🧩 Official patches by ReVanced
|
Official patches by ReVanced
|
||||||
|
|
||||||
# List of available patches
|
## 📜 List of available patches
|
||||||
|
|
||||||
| 💊 Patch | 📜 Description | 🎯 Target Package | 🏹 Target Version |
|
|
||||||
|:--------:|:--------------:|:-----------------:|:-----------------:|
|
|
||||||
{{ table }}
|
{{ table }}
|
||||||
|
11
src/main/kotlin/app/revanced/meta/readme/Extensions.kt
Normal file
11
src/main/kotlin/app/revanced/meta/readme/Extensions.kt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package app.revanced.meta.readme
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.Data
|
||||||
|
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
|
|
||||||
|
internal fun Class<out Patch<Data>>.getLatestVersion(): SemanticVersion? =
|
||||||
|
this.compatiblePackages?.first()?.versions?.map { SemanticVersion.fromString(it) }
|
||||||
|
?.maxWithOrNull(
|
||||||
|
SemanticVersionComparator
|
||||||
|
)
|
@ -1,13 +1,18 @@
|
|||||||
package app.revanced.meta.readme
|
package app.revanced.meta.readme
|
||||||
|
|
||||||
|
import app.revanced.patcher.data.Data
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
import app.revanced.patcher.extensions.PatchExtensions.compatiblePackages
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.description
|
import app.revanced.patcher.extensions.PatchExtensions.description
|
||||||
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
import app.revanced.patcher.extensions.PatchExtensions.patchName
|
||||||
|
import app.revanced.patcher.patch.Patch
|
||||||
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
import app.revanced.patcher.util.patch.implementation.JarPatchBundle
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class Generator {
|
object Generator {
|
||||||
companion object {
|
private const val TABLE_HEADER =
|
||||||
|
"| \uD83D\uDC8A Patch | \uD83D\uDCDC Description | \uD83C\uDFF9 Target Version |\n" +
|
||||||
|
"|:--------:|:--------------:|:-----------------:|"
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
val buildDir = File("build/libs/")
|
val buildDir = File("build/libs/")
|
||||||
@ -16,26 +21,31 @@ class Generator {
|
|||||||
|
|
||||||
val bundle = JarPatchBundle(buildJar.absolutePath).loadPatches()
|
val bundle = JarPatchBundle(buildJar.absolutePath).loadPatches()
|
||||||
|
|
||||||
val patches = StringBuilder()
|
val output = StringBuilder()
|
||||||
|
|
||||||
for (patch in bundle) {
|
val packages = mutableMapOf<String, MutableList<Class<out Patch<Data>>>>()
|
||||||
val patchName = patch.patchName
|
|
||||||
val compatiblePackage = patch.compatiblePackages?.first()
|
|
||||||
val latestVersion =
|
|
||||||
compatiblePackage?.versions?.map { SemanticVersion.fromString(it) }?.maxWithOrNull(
|
|
||||||
SemanticVersionComparator
|
|
||||||
) ?: "all"
|
|
||||||
|
|
||||||
patches.appendLine("| `$patchName` | ${patch.description} | `${compatiblePackage?.name}` | $latestVersion |")
|
bundle.map {
|
||||||
|
val packageName = it.compatiblePackages?.first()?.name!!
|
||||||
|
packages.getOrElse(packageName) { packages.put(packageName, mutableListOf()) }?.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
for (pkg in packages) {
|
||||||
|
output.appendLine("### \uD83D\uDCE6 `${pkg.key}`")
|
||||||
|
output.appendLine("<details>\n")
|
||||||
|
|
||||||
|
output.appendLine(TABLE_HEADER)
|
||||||
|
pkg.value.forEach { output.appendLine("| `${it.patchName}` | ${it.description} | ${it.getLatestVersion() ?: "all"} |") }
|
||||||
|
|
||||||
|
output.appendLine("</details>\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
val readMeTemplateFile = File("README-template.md")
|
val readMeTemplateFile = File("README-template.md")
|
||||||
val readmeTemplate = Template(readMeTemplateFile.readText())
|
val readmeTemplate = Template(readMeTemplateFile.readText())
|
||||||
|
|
||||||
readmeTemplate.replaceVariable("table", patches.toString())
|
readmeTemplate.replaceVariable("table", output.toString())
|
||||||
|
|
||||||
val readme = File("README.md")
|
val readme = File("README.md")
|
||||||
readme.writeText(readmeTemplate.toString())
|
readme.writeText(readmeTemplate.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user