From f887404d3384e7d7b6486eda353cbcd0c18931fa Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 23 Jul 2020 10:52:05 -0700 Subject: [PATCH] Added KDoc for public functions, etc. --- .../thauvin/erik/readingtime/ReadingTime.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt b/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt index c757cba..4045cf7 100644 --- a/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt +++ b/src/main/kotlin/net/thauvin/erik/readingtime/ReadingTime.kt @@ -7,7 +7,13 @@ import java.math.RoundingMode /** * Calculates the reading time of the given [text]. * - * Calculation based on this [Medium's Post](https://blog.medium.com/read-time-and-you-bc2048ab620c) + * Based on [Medium's calculation](https://blog.medium.com/read-time-and-you-bc2048ab620c). + * + * @param text The text to be evaluated. + * @param wpm The words per minute reading average. + * @param postfix The value to be appended to the reading time. + * @param plural The value to be appended if the reading time is more than 1 minute. + * @param excludeImages Images are excluded from the reading time when set. */ class ReadingTime( var text: String, @@ -17,18 +23,29 @@ class ReadingTime( var excludeImages: Boolean = false ) { companion object { + /** + * Counts words. + * + * HTML tags are stripped. + */ @JvmStatic fun wordCount(words: String): Int { val s = Jsoup.parse(words).text().trim() return if (s.isEmpty()) 0 else s.split("\\s+".toRegex()).size } + /** + * Counts HTML img tags. + */ @JvmStatic fun imgCount(html: String): Int { return "