From 92861602f619e9a5a99e4034b9dc8c5874a3596b Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 May 2024 14:17:57 -0400 Subject: [PATCH 1/2] docs(text): pass check_docs.ts --- _tools/check_docs.ts | 3 ++- text/case.ts | 8 ++++---- text/closest_string.ts | 9 +++++---- text/compare_similarity.ts | 9 ++++++++- text/levenshtein_distance.ts | 2 +- text/word_similarity_sort.ts | 5 +++-- 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/_tools/check_docs.ts b/_tools/check_docs.ts index 74cde65e6bba..997939720969 100644 --- a/_tools/check_docs.ts +++ b/_tools/check_docs.ts @@ -33,6 +33,7 @@ const ENTRY_POINTS = [ "../internal/mod.ts", "../jsonc/mod.ts", "../media_types/mod.ts", + "../text/mod.ts", "../ulid/mod.ts", "../webgpu/mod.ts", ] as const; @@ -84,7 +85,7 @@ function assertHasReturnTag(document: { jsDoc: JsDoc; location: Location }) { const tag = document.jsDoc.tags?.find((tag) => tag.kind === "return"); if (tag === undefined) { diagnostics.push( - new DocumentError("Symbol must have a @return tag", document), + new DocumentError("Symbol must have a @returns tag", document), ); } else { assert( diff --git a/text/case.ts b/text/case.ts index b9bacdb2369b..f017e15a4dd1 100644 --- a/text/case.ts +++ b/text/case.ts @@ -6,7 +6,7 @@ import { capitalizeWord, splitToWords } from "./_util.ts"; /** * Converts a string into camelCase. * - * @example + * @example Usage * ```ts * import { toCamelCase } from "@std/text/case"; * @@ -25,7 +25,7 @@ export function toCamelCase(input: string): string { /** * Converts a string into kebab-case. * - * @example + * @example Usage * ```ts * import { toKebabCase } from "@std/text/case"; * @@ -43,7 +43,7 @@ export function toKebabCase(input: string): string { /** * Converts a string into PascalCase. * - * @example + * @example Usage * ```ts * import { toPascalCase } from "@std/text/case"; * @@ -61,7 +61,7 @@ export function toPascalCase(input: string): string { /** * Converts a string into snake_case. * - * @example + * @example Usage * ```ts * import { toSnakeCase } from "@std/text/case"; * toSnakeCase("deno is awesome"); // "deno_is_awesome" diff --git a/text/closest_string.ts b/text/closest_string.ts index ec4dab0ffa8e..08a964ffd7a7 100644 --- a/text/closest_string.ts +++ b/text/closest_string.ts @@ -9,7 +9,7 @@ const getWordDistance = levenshteinDistance; /** * get most-similar word * - * @example + * @example Usage * ```ts * import { closestString } from "@std/text/closest-string"; * @@ -19,9 +19,10 @@ const getWordDistance = levenshteinDistance; * const word = closestString("hep", possibleWords); * ``` * - * @param givenWord - The string to measure distance against - * @param possibleWords - The string-array that will be sorted - * @param options.caseSensitive - Flag indicating whether the distance should include case. Default is false. + * @param givenWord The string to measure distance against + * @param possibleWords The string-array that will be sorted + * @param options An options bag containing a `caseSensitive` flag indicating + * whether the distance should include case. Default is false. * @returns A sorted copy of possibleWords * @note * the ordering of words may change with version-updates diff --git a/text/compare_similarity.ts b/text/compare_similarity.ts index 805e4dcd633c..920d062f9a98 100644 --- a/text/compare_similarity.ts +++ b/text/compare_similarity.ts @@ -8,7 +8,14 @@ const getWordDistance = levenshteinDistance; /** * Sort based on word similarity * - * @example + * @param givenWord The string to measure distance against. + * @param options An options bag containing a `caseSensitive` flag indicating + * whether the distance should include case. Default is false. + * @returns The difference in distance. This will be a negative number if `a` + * is more similar to `givenWord` than `b`, a positive number if `b` is more + * similar, or `0` if they are equally similar. + * + * @example Usage * ```ts * import { compareSimilarity } from "@std/text/compare-similarity"; * const words = ["hi", "hello", "help"]; diff --git a/text/levenshtein_distance.ts b/text/levenshtein_distance.ts index 6c8842678680..00cab78f9b7a 100644 --- a/text/levenshtein_distance.ts +++ b/text/levenshtein_distance.ts @@ -4,7 +4,7 @@ /** * Calculates the Levenshtein distance between two strings. * - * @example + * @example Usage * ```ts * import { levenshteinDistance } from "@std/text/levenshtein-distance"; * levenshteinDistance("aa", "bb"); // 2 diff --git a/text/word_similarity_sort.ts b/text/word_similarity_sort.ts index 2f0d9265ea16..82e8df008194 100644 --- a/text/word_similarity_sort.ts +++ b/text/word_similarity_sort.ts @@ -5,7 +5,7 @@ import { compareSimilarity } from "./compare_similarity.ts"; /** * Sorts a string-array by similarity to a given string * - * @example + * @example Usage * ```ts * import { wordSimilaritySort } from "@std/text/word-similarity-sort"; * @@ -20,7 +20,8 @@ import { compareSimilarity } from "./compare_similarity.ts"; * * @param givenWord - The string to measure distance against * @param possibleWords - The string-array that will be sorted - * @param options.caseSensitive - Flag indicating whether the distance should include case. Default is false. + * @param options An options bag containing a `caseSensitive` flag indicating + * whether the distance should include case. Default is false. * @returns {string[]} A sorted copy of possibleWords */ export function wordSimilaritySort( From 61612e01a7f120f43c625dd99e814b5b18ee03db Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 23 May 2024 12:57:01 -0400 Subject: [PATCH 2/2] Update _tools/check_docs.ts Co-authored-by: Asher Gomez --- _tools/check_docs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_tools/check_docs.ts b/_tools/check_docs.ts index 997939720969..37b6d54e965e 100644 --- a/_tools/check_docs.ts +++ b/_tools/check_docs.ts @@ -85,7 +85,7 @@ function assertHasReturnTag(document: { jsDoc: JsDoc; location: Location }) { const tag = document.jsDoc.tags?.find((tag) => tag.kind === "return"); if (tag === undefined) { diagnostics.push( - new DocumentError("Symbol must have a @returns tag", document), + new DocumentError("Symbol must have a @return or @returns tag", document), ); } else { assert(