From fbd181f8bf0f9db0c17192ebabcd692d92fc58ca Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 3 Feb 2024 14:40:22 +0200 Subject: [PATCH] Broken parser annotation --- .../org/koitharu/kotatsu/parsers/ksp/ParserProcessor.kt | 8 +++++--- src/main/kotlin/org/koitharu/kotatsu/parsers/Broken.kt | 8 ++++++++ .../org/koitharu/kotatsu/parsers/MangaSourceParser.kt | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 src/main/kotlin/org/koitharu/kotatsu/parsers/Broken.kt diff --git a/kotatsu-parsers-ksp/src/main/kotlin/org/koitharu/kotatsu/parsers/ksp/ParserProcessor.kt b/kotatsu-parsers-ksp/src/main/kotlin/org/koitharu/kotatsu/parsers/ksp/ParserProcessor.kt index 3c684bad8..9c27b9eba 100644 --- a/kotatsu-parsers-ksp/src/main/kotlin/org/koitharu/kotatsu/parsers/ksp/ParserProcessor.kt +++ b/kotatsu-parsers-ksp/src/main/kotlin/org/koitharu/kotatsu/parsers/ksp/ParserProcessor.kt @@ -85,8 +85,9 @@ class ParserProcessor( val title: String, val locale: String?, val contentType: ContentType, + val isBroken: Boolean, ) { - LOCAL("Local", null, ContentType.OTHER), + LOCAL("Local", null, ContentType.OTHER, false), """.trimIndent(), ) @@ -109,7 +110,7 @@ class ParserProcessor( ) sourcesWriter?.write( """ - DUMMY("Dummy", null, ContentType.OTHER), + DUMMY("Dummy", null, ContentType.OTHER, false), ; } """.trimIndent(), @@ -129,6 +130,7 @@ class ParserProcessor( } val annotation = classDeclaration.annotations.single { it.shortName.asString() == "MangaSourceParser" } val deprecation = classDeclaration.annotations.singleOrNull { it.shortName.asString() == "Deprecated" } + val isBroken = classDeclaration.annotations.any { it.shortName.asString() == "Broken" } val name = annotation.arguments.single { it.name?.asString() == "name" }.value as String val title = annotation.arguments.single { it.name?.asString() == "title" }.value as String val locale = annotation.arguments.single { it.name?.asString() == "locale" }.value as String @@ -165,7 +167,7 @@ class ParserProcessor( "@Deprecated(\"$reason\") " } else "" val localeComment = localeTitle?.toTitleCase(localeObj)?.let { " /* $it */" }.orEmpty() - sourcesWriter?.write("\t$deprecationString$name(\"$title\", $localeString$localeComment, ContentType.$type),\n") + sourcesWriter?.write("\t$deprecationString$name(\"$title\", $localeString$localeComment, ContentType.$type, $isBroken),\n") } } } diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/Broken.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/Broken.kt new file mode 100644 index 000000000..8e4bea1ac --- /dev/null +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/Broken.kt @@ -0,0 +1,8 @@ +package org.koitharu.kotatsu.parsers + +/** + * Annotate [MangaParser] implementation to mark this parser as broken instead of removing it + */ +@Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) +annotation class Broken diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaSourceParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaSourceParser.kt index b091aa01e..ebb45e677 100644 --- a/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaSourceParser.kt +++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/MangaSourceParser.kt @@ -6,6 +6,7 @@ import org.koitharu.kotatsu.parsers.model.ContentType * Annotate each [MangaParser] implementation with this annotation, used by codegen */ @Target(AnnotationTarget.CLASS) +@Retention(AnnotationRetention.SOURCE) annotation class MangaSourceParser( /** * Name of manga source. Used as an Enum value, must be UPPER_CASE and unique.