Broken parser annotation

Koitharu 2 years ago
parent 26be293f24
commit cc35aa6bc3

@ -85,8 +85,9 @@ class ParserProcessor(
val title: String, val title: String,
val locale: String?, val locale: String?,
val contentType: ContentType, val contentType: ContentType,
val isBroken: Boolean,
) { ) {
LOCAL("Local", null, ContentType.OTHER), LOCAL("Local", null, ContentType.OTHER, false),
""".trimIndent(), """.trimIndent(),
) )
@ -109,7 +110,7 @@ class ParserProcessor(
) )
sourcesWriter?.write( sourcesWriter?.write(
""" """
DUMMY("Dummy", null, ContentType.OTHER), DUMMY("Dummy", null, ContentType.OTHER, false),
; ;
} }
""".trimIndent(), """.trimIndent(),
@ -129,6 +130,7 @@ class ParserProcessor(
} }
val annotation = classDeclaration.annotations.single { it.shortName.asString() == "MangaSourceParser" } val annotation = classDeclaration.annotations.single { it.shortName.asString() == "MangaSourceParser" }
val deprecation = classDeclaration.annotations.singleOrNull { it.shortName.asString() == "Deprecated" } 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 name = annotation.arguments.single { it.name?.asString() == "name" }.value as String
val title = annotation.arguments.single { it.name?.asString() == "title" }.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 val locale = annotation.arguments.single { it.name?.asString() == "locale" }.value as String
@ -165,7 +167,7 @@ class ParserProcessor(
"@Deprecated(\"$reason\") " "@Deprecated(\"$reason\") "
} else "" } else ""
val localeComment = localeTitle?.toTitleCase(localeObj)?.let { " /* $it */" }.orEmpty() 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")
} }
} }
} }

@ -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

@ -6,6 +6,7 @@ import org.koitharu.kotatsu.parsers.model.ContentType
* Annotate each [MangaParser] implementation with this annotation, used by codegen * Annotate each [MangaParser] implementation with this annotation, used by codegen
*/ */
@Target(AnnotationTarget.CLASS) @Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class MangaSourceParser( annotation class MangaSourceParser(
/** /**
* Name of manga source. Used as an Enum value, must be UPPER_CASE and unique. * Name of manga source. Used as an Enum value, must be UPPER_CASE and unique.

Loading…
Cancel
Save