Remove DUMMY parser

Koitharu 8 months ago
parent 6ca07aeff7
commit fe5534b006
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -63,12 +63,14 @@ All members of the `MangaParser` class are documented. Pay attention to some pec
- You can use _asserts_ to check some optional fields. For example, the `Manga.author` field is not required, but if - You can use _asserts_ to check some optional fields. For example, the `Manga.author` field is not required, but if
your source provides this information, add `assert(it != null)`. This will not have any effect on production but help your source provides this information, add `assert(it != null)`. This will not have any effect on production but help
to find issues during unit testing. to find issues during unit testing.
- Your parser may also implement the `Interceptor` interface for additional manipulation of all network requests and
responses, including image loading.
- If your source website (or its API) uses pages for pagination instead of offset you should extend `PagedMangaParser` - If your source website (or its API) uses pages for pagination instead of offset you should extend `PagedMangaParser`
instead of `MangaParser`. instead of `MangaParser`.
- If your source website (or its API) does not provide pagination (has only one page of content) you should extend - If your source website (or its API) does not provide pagination (has only one page of content) you should extend
`SinglePageMangaParser` instead of `MangaParser` or `PagedMangaParser`. `SinglePageMangaParser` instead of `MangaParser` or `PagedMangaParser`.
- Your parser may also implement the `Interceptor` interface for additional manipulation of all network requests and
responses, including image loading. ![parser_classes.png](docs/parser_classes.png)
## Development process ## Development process

@ -53,11 +53,9 @@ JVM and Android applications.
`mangaLoaderContext` is an implementation of the `MangaLoaderContext` class. `mangaLoaderContext` is an implementation of the `MangaLoaderContext` class.
See examples See examples
of [Android](https://github.com/KotatsuApp/Kotatsu/blob/devel/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/MangaLoaderContextImpl.kt) of [Android](https://github.com/KotatsuApp/Kotatsu/blob/devel/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/MangaLoaderContextImpl.kt)
and [Non-Android](https://github.com/KotatsuApp/kotatsu-dl/blob/master/src/jvmMain/kotlin/org/koitharu/kotatsu_dl/logic/MangaLoaderContextImpl.kt) and [Non-Android](https://github.com/KotatsuApp/kotatsu-dl/blob/master/src/main/kotlin/org/koitharu/kotatsu/dl/parsers/MangaLoaderContextImpl.kt)
implementation. implementation.
Note that the `MangaParserSource.DUMMY` parsers cannot be instantiated.
## Projects that use the library ## Projects that use the library
- [Kotatsu](https://github.com/KotatsuApp/Kotatsu) - [Kotatsu](https://github.com/KotatsuApp/Kotatsu)

@ -98,7 +98,6 @@ class ParserProcessor(
factoryWriter?.write( factoryWriter?.write(
""" """
MangaParserSource.DUMMY -> throw NotImplementedError("Manga parser ${'$'}name cannot be instantiated")
}.let { }.let {
require(it.source == this) { require(it.source == this) {
"Cannot instantiate manga parser: ${'$'}name mapped to ${'$'}{it.source}" "Cannot instantiate manga parser: ${'$'}name mapped to ${'$'}{it.source}"
@ -109,7 +108,6 @@ class ParserProcessor(
) )
sourcesWriter?.write( sourcesWriter?.write(
""" """
DUMMY("Dummy", "", ContentType.OTHER, false),
; ;
} }
""".trimIndent(), """.trimIndent(),

@ -1,8 +1,8 @@
package org.koitharu.kotatsu.parsers package org.koitharu.kotatsu.parsers
import org.junit.jupiter.params.provider.EnumSource import org.junit.jupiter.params.provider.EnumSource
import org.junit.jupiter.params.provider.EnumSource.Mode.EXCLUDE
import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaParserSource
@EnumSource(MangaParserSource::class, names = ["DUMMY"], mode = EXCLUDE) // Change 'names' to test specified parsers
@EnumSource(MangaParserSource::class, names = [], mode = EnumSource.Mode.INCLUDE)
internal annotation class MangaSources internal annotation class MangaSources

@ -68,5 +68,5 @@ class MangaSearchQueryCapabilitiesTest {
assertThrows(IllegalArgumentException::class.java) { capabilities.validate(query) } assertThrows(IllegalArgumentException::class.java) { capabilities.validate(query) }
} }
private fun buildTag(name: String) = MangaTag(title = name, key = "${name}Key", source = MangaParserSource.DUMMY) private fun buildTag(name: String) = MangaTag(title = name, key = "${name}Key", source = MangaParserSource.MANGADEX)
} }

@ -22,9 +22,6 @@ class IntentFilterGenerator {
writer.appendTab().appendLine("<data android:scheme=\"https\" />") writer.appendTab().appendLine("<data android:scheme=\"https\" />")
writer.appendLine() writer.appendLine()
for (source in MangaParserSource.entries) { for (source in MangaParserSource.entries) {
if (source == MangaParserSource.DUMMY) {
continue
}
val parser = source.newParser(MangaLoaderContextMock) val parser = source.newParser(MangaLoaderContextMock)
parser.configKeyDomain.presetValues.forEach { domain -> parser.configKeyDomain.presetValues.forEach { domain ->
writer.appendTab().append("<data android:host=\"").append(domain).appendLine("\" />") writer.appendTab().append("<data android:host=\"").append(domain).appendLine("\" />")

@ -71,7 +71,7 @@ class ListFilterToSearchQueryConverterTest {
return MangaTag( return MangaTag(
key = "${name}Key", key = "${name}Key",
title = name, title = name,
source = MangaParserSource.DUMMY, source = MangaParserSource.MANGADEX,
) )
} }
} }

@ -88,7 +88,7 @@ class ConvertToMangaListFilterTest {
return MangaTag( return MangaTag(
key = "${name}Key", key = "${name}Key",
title = name, title = name,
source = MangaParserSource.DUMMY, source = MangaParserSource.MANGADEX,
) )
} }
} }

Loading…
Cancel
Save