From 4efb7b538b79c643945432572ef9a1abfd2eed7d Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Fri, 12 Jan 2024 13:26:41 +1100 Subject: [PATCH] docs(jsonc): complete documentation --- jsonc/parse.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/jsonc/parse.ts b/jsonc/parse.ts index b5001c5364f0..3e44708a11b5 100644 --- a/jsonc/parse.ts +++ b/jsonc/parse.ts @@ -1,8 +1,9 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. -/** {@linkcode parse} function for parsing - * [JSONC](https://code.visualstudio.com/docs/languages/json#_json-with-comments) +/** + * {@linkcode parse} function for parsing + * {@link https://code.visualstudio.com/docs/languages/json#_json-with-comments | JSONC} * (JSON with Comments) strings. * * This module is browser compatible. @@ -15,6 +16,7 @@ import { assert } from "../assert/assert.ts"; import type { JsonValue } from "../json/common.ts"; export type { JsonValue } from "../json/common.ts"; +/** Options for {@linkcode parse}. */ export interface ParseOptions { /** Allow trailing commas at the end of arrays and objects. * @@ -25,18 +27,17 @@ export interface ParseOptions { /** * Converts a JSON with Comments (JSONC) string into an object. - * If a syntax error is found, throw a SyntaxError. + * If a syntax error is found, throw a {@linkcode SyntaxError}. * * @example - * * ```ts - * import * as JSONC from "https://deno.land/std@$STD_VERSION/jsonc/mod.ts"; + * import { parse } from "https://deno.land/std@$STD_VERSION/jsonc/mod.ts"; * - * console.log(JSONC.parse('{"foo": "bar", } // comment')); //=> { foo: "bar" } - * console.log(JSONC.parse('{"foo": "bar", } /* comment *\/')); //=> { foo: "bar" } - * console.log(JSONC.parse('{"foo": "bar" } // comment', { + * console.log(parse('{"foo": "bar", } // comment')); // { foo: "bar" } + * console.log(parse('{"foo": "bar", } /* comment *\/')); // { foo: "bar" } + * console.log(parse('{"foo": "bar" } // comment', { * allowTrailingComma: false, - * })); //=> { foo: "bar" } + * })); // { foo: "bar" } * ``` * * @param text A valid JSONC string.