From 3736b01a7d0013b80858f1026fa36eacfb39fdc2 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 28 Feb 2024 06:28:34 +1100 Subject: [PATCH] docs(jsonc): add module-level docs (#4402) * docs(jsonc): add module-level docs * Yoshiya's suggestion --- jsonc/mod.ts | 20 ++++++++++++++++++++ jsonc/parse.ts | 8 ++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/jsonc/mod.ts b/jsonc/mod.ts index 1a02f1a49..57d7e2cba 100644 --- a/jsonc/mod.ts +++ b/jsonc/mod.ts @@ -1,4 +1,24 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. +/** + * Provides tools for working with JSONC (JSON with comments). Currently, this + * module only provides a means of parsing JSONC. JSONC serialization is not + * yet supported. + * + * This module is browser compatible. + * + * @example + * ```ts Parsing JSONC + * import { parse } from "https://deno.land/std@$STD_VERSION/jsonc/mod.ts"; + * + * parse('{"foo": "bar", } // comment'); // { foo: "bar" } + * parse('{"foo": "bar", } /* comment *\/'); // { foo: "bar" } + * parse('{"foo": "bar" } // comment', { + * allowTrailingComma: false, + * }); // { foo: "bar" } + * ``` + * + * @module + */ export * from "./parse.ts"; diff --git a/jsonc/parse.ts b/jsonc/parse.ts index 3e44708a1..fd6cd1d86 100644 --- a/jsonc/parse.ts +++ b/jsonc/parse.ts @@ -33,11 +33,11 @@ export interface ParseOptions { * ```ts * import { parse } from "https://deno.land/std@$STD_VERSION/jsonc/mod.ts"; * - * console.log(parse('{"foo": "bar", } // comment')); // { foo: "bar" } - * console.log(parse('{"foo": "bar", } /* comment *\/')); // { foo: "bar" } - * console.log(parse('{"foo": "bar" } // comment', { + * parse('{"foo": "bar", } // comment'); // { foo: "bar" } + * parse('{"foo": "bar", } /* comment *\/'); // { foo: "bar" } + * parse('{"foo": "bar" } // comment', { * allowTrailingComma: false, - * })); // { foo: "bar" } + * }); // { foo: "bar" } * ``` * * @param text A valid JSONC string.