From 07b1339e4d4351ae721a3111e65cc8d21e696677 Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Wed, 29 May 2024 17:39:33 +0900 Subject: [PATCH] docs(html): improve API docs --- _tools/check_docs.ts | 1 + html/entities.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/_tools/check_docs.ts b/_tools/check_docs.ts index 30b95f4476df..9b96cbf84d2b 100644 --- a/_tools/check_docs.ts +++ b/_tools/check_docs.ts @@ -39,6 +39,7 @@ const ENTRY_POINTS = [ "../fmt/duration.ts", "../fmt/printf.ts", "../front_matter/mod.ts", + "../html/mod.ts", "../http/mod.ts", "../internal/mod.ts", "../jsonc/mod.ts", diff --git a/html/entities.ts b/html/entities.ts index 04800bf267d2..77d17c659975 100644 --- a/html/entities.ts +++ b/html/entities.ts @@ -25,7 +25,7 @@ const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g"); /** * Escapes text for safe interpolation into HTML text content and quoted attributes. * - * @example + * @example Usage * ```ts * import { escape } from "@std/html/entities"; * @@ -35,6 +35,9 @@ const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g"); * // even if named HTML entities exist for them. * escape("þð"); // "þð" * ``` + * + * @param str The string to escape. + * @returns The escaped string. */ export function escape(str: string): string { return str.replaceAll(rawRe, (m) => rawToEntity.get(m)!); @@ -57,7 +60,7 @@ const entityListRegexCache = new WeakMap(); /** * Unescapes HTML entities in text. * - * @example + * @example Usage * ```ts * import { unescape } from "@std/html/entities"; * @@ -70,6 +73,10 @@ const entityListRegexCache = new WeakMap(); * * unescape("þð", { entityList }); // "þð" * ``` + * + * @param str The string to unescape. + * @param options Options for unescaping. + * @returns The unescaped string. */ export function unescape( str: string,