Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken parser annotation #537

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand All @@ -109,7 +110,7 @@ class ParserProcessor(
)
sourcesWriter?.write(
"""
DUMMY("Dummy", null, ContentType.OTHER),
DUMMY("Dummy", null, ContentType.OTHER, false),
;
}
""".trimIndent(),
Expand All @@ -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
Expand Down Expand Up @@ -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")
}
}
}
8 changes: 8 additions & 0 deletions src/main/kotlin/org/koitharu/kotatsu/parsers/Broken.kt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading