diff --git a/encoding/front_matter/any.ts b/encoding/front_matter/any.ts index df32e4a96c04..2474e0e41336 100644 --- a/encoding/front_matter/any.ts +++ b/encoding/front_matter/any.ts @@ -1,7 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. import { createExtractor, Format, Parser, test as _test } from "./mod.ts"; -import { parse as parseYAML } from "../yaml.ts"; +import { parse as parseYAML } from "../yaml/mod.ts"; import { parse as parseTOML } from "../toml.ts"; export { Format, test } from "./mod.ts"; diff --git a/encoding/front_matter/mod.ts b/encoding/front_matter/mod.ts index 06e21d95d284..172f0c47bacd 100644 --- a/encoding/front_matter/mod.ts +++ b/encoding/front_matter/mod.ts @@ -246,7 +246,7 @@ function _extract( * ```ts * import { createExtractor, Format, Parser } from "https://deno.land/std@$STD_VERSION/encoding/front_matter/mod.ts"; * import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts"; - * import { parse as parseYAML } from "https://deno.land/std@$STD_VERSION/encoding/yaml.ts"; + * import { parse as parseYAML } from "https://deno.land/std@$STD_VERSION/encoding/yaml/mod.ts"; * import { parse as parseTOML } from "https://deno.land/std@$STD_VERSION/encoding/toml.ts"; * const extractYAML = createExtractor({ [Format.YAML]: parseYAML as Parser }); * const extractTOML = createExtractor({ [Format.TOML]: parseTOML as Parser }); diff --git a/encoding/front_matter/mod_test.ts b/encoding/front_matter/mod_test.ts index 898e871226fa..d518632bb4a3 100644 --- a/encoding/front_matter/mod_test.ts +++ b/encoding/front_matter/mod_test.ts @@ -2,7 +2,7 @@ import { assert, assertThrows } from "../../testing/asserts.ts"; import { createExtractor, Format, Parser, test } from "./mod.ts"; -import { parse as parseYAML } from "../yaml.ts"; +import { parse as parseYAML } from "../yaml/mod.ts"; import { parse as parseTOML } from "../toml.ts"; import { resolveTestDataPath, diff --git a/encoding/front_matter/yaml.ts b/encoding/front_matter/yaml.ts index c44a338dcb5f..f89dd6fab174 100644 --- a/encoding/front_matter/yaml.ts +++ b/encoding/front_matter/yaml.ts @@ -1,7 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. import { createExtractor, Format, Parser, test as _test } from "./mod.ts"; -import { parse } from "../yaml.ts"; +import { parse } from "../yaml/mod.ts"; export { Format } from "./mod.ts"; export function test(str: string): boolean { diff --git a/encoding/yaml.ts b/encoding/yaml.ts index c70d3328af22..c0c4b6726fa7 100644 --- a/encoding/yaml.ts +++ b/encoding/yaml.ts @@ -1,62 +1,4 @@ -// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license. // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -/** - * {@linkcode parse} and {@linkcode stringify} for handling - * [YAML](https://yaml.org/) encoded data. - * - * Ported from - * [js-yaml v3.13.1](https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da) - * - * If your YAML contains multiple documents in it, you can use {@linkcode parseAll} for - * handling it. - * - * To handle `regexp`, and `undefined` types, use {@linkcode EXTENDED_SCHEMA}. - * You can also use custom types by extending schemas. - * - * ## :warning: Limitations - * - `binary` type is currently not stable. - * - * For further examples see https://github.com/nodeca/js-yaml/tree/master/examples. - * @example - * ```ts - * import { - * parse, - * stringify, - * } from "https://deno.land/std@$STD_VERSION/encoding/yaml.ts"; - * - * const data = parse(` - * foo: bar - * baz: - * - qux - * - quux - * `); - * console.log(data); - * // => { foo: "bar", baz: [ "qux", "quux" ] } - * - * const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] }); - * console.log(yaml); - * // => - * // foo: bar - * // baz: - * // - qux - * // - quux - * ``` - * - * @module - */ - -export type { ParseOptions } from "./_yaml/parse.ts"; -export { parse, parseAll } from "./_yaml/parse.ts"; -export type { DumpOptions as StringifyOptions } from "./_yaml/stringify.ts"; -export { stringify } from "./_yaml/stringify.ts"; -export type { SchemaDefinition } from "./_yaml/schema.ts"; -export { Type } from "./_yaml/type.ts"; -export type { KindType, RepresentFn, StyleVariant } from "./_yaml/type.ts"; -export { - CORE_SCHEMA, - DEFAULT_SCHEMA, - EXTENDED_SCHEMA, - FAILSAFE_SCHEMA, - JSON_SCHEMA, -} from "./_yaml/schema/mod.ts"; +/** @deprecated (will be removed after 0.170.0) use the extended API under std/encoding/yaml/ instead */ +export * from "./yaml/mod.ts"; diff --git a/encoding/_yaml/dumper/dumper.ts b/encoding/yaml/_util/dumper/dumper.ts similarity index 100% rename from encoding/_yaml/dumper/dumper.ts rename to encoding/yaml/_util/dumper/dumper.ts diff --git a/encoding/_yaml/dumper/dumper_state.ts b/encoding/yaml/_util/dumper/dumper_state.ts similarity index 100% rename from encoding/_yaml/dumper/dumper_state.ts rename to encoding/yaml/_util/dumper/dumper_state.ts diff --git a/encoding/_yaml/error.ts b/encoding/yaml/_util/error.ts similarity index 100% rename from encoding/_yaml/error.ts rename to encoding/yaml/_util/error.ts diff --git a/encoding/_yaml/example/dump.ts b/encoding/yaml/_util/example/dump.ts similarity index 100% rename from encoding/_yaml/example/dump.ts rename to encoding/yaml/_util/example/dump.ts diff --git a/encoding/_yaml/example/inout.ts b/encoding/yaml/_util/example/inout.ts similarity index 88% rename from encoding/_yaml/example/inout.ts rename to encoding/yaml/_util/example/inout.ts index f283b882059d..a484efb5c972 100644 --- a/encoding/_yaml/example/inout.ts +++ b/encoding/yaml/_util/example/inout.ts @@ -1,6 +1,6 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { parse, stringify } from "../../yaml.ts"; +import { parse, stringify } from "../../../yaml/mod.ts"; const test = { foo: { diff --git a/encoding/_yaml/example/parse.ts b/encoding/yaml/_util/example/parse.ts similarity index 100% rename from encoding/_yaml/example/parse.ts rename to encoding/yaml/_util/example/parse.ts diff --git a/encoding/_yaml/example/sample_document.ts b/encoding/yaml/_util/example/sample_document.ts similarity index 91% rename from encoding/_yaml/example/sample_document.ts rename to encoding/yaml/_util/example/sample_document.ts index 16c97a5c94b1..c444799b8a43 100644 --- a/encoding/_yaml/example/sample_document.ts +++ b/encoding/yaml/_util/example/sample_document.ts @@ -1,6 +1,6 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { parse } from "../../yaml.ts"; +import { parse } from "../../../yaml/mod.ts"; (() => { const yml = Deno.readFileSync(`${Deno.cwd()}/example/sample_document.yml`); diff --git a/encoding/_yaml/example/sample_document.yml b/encoding/yaml/_util/example/sample_document.yml similarity index 100% rename from encoding/_yaml/example/sample_document.yml rename to encoding/yaml/_util/example/sample_document.yml diff --git a/encoding/_yaml/loader/loader.ts b/encoding/yaml/_util/loader/loader.ts similarity index 100% rename from encoding/_yaml/loader/loader.ts rename to encoding/yaml/_util/loader/loader.ts diff --git a/encoding/_yaml/loader/loader_state.ts b/encoding/yaml/_util/loader/loader_state.ts similarity index 100% rename from encoding/_yaml/loader/loader_state.ts rename to encoding/yaml/_util/loader/loader_state.ts diff --git a/encoding/_yaml/mark.ts b/encoding/yaml/_util/mark.ts similarity index 100% rename from encoding/_yaml/mark.ts rename to encoding/yaml/_util/mark.ts diff --git a/encoding/_yaml/parse.ts b/encoding/yaml/_util/parse.ts similarity index 98% rename from encoding/_yaml/parse.ts rename to encoding/yaml/_util/parse.ts index a503305c5d14..54d793101207 100644 --- a/encoding/_yaml/parse.ts +++ b/encoding/yaml/_util/parse.ts @@ -24,7 +24,7 @@ export function parse(content: string, options?: ParseOptions): unknown { * * @example * ```ts - * import { parseAll } from "https://deno.land/std@$STD_VERSION/encoding/yaml.ts"; + * import { parseAll } from "https://deno.land/std@$STD_VERSION/encoding/yaml/mod.ts"; * * const data = parseAll(` * --- diff --git a/encoding/_yaml/parse_test.ts b/encoding/yaml/_util/parse_test.ts similarity index 97% rename from encoding/_yaml/parse_test.ts rename to encoding/yaml/_util/parse_test.ts index f95c47b670c6..ecbcf7e6dee8 100644 --- a/encoding/_yaml/parse_test.ts +++ b/encoding/yaml/_util/parse_test.ts @@ -4,7 +4,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. import { parse, parseAll } from "./parse.ts"; -import { assertEquals, assertThrows } from "../../testing/asserts.ts"; +import { assertEquals, assertThrows } from "../../../testing/asserts.ts"; import { DEFAULT_SCHEMA, EXTENDED_SCHEMA } from "./schema/mod.ts"; import { YAMLError } from "./error.ts"; import { Type } from "./type.ts"; diff --git a/encoding/_yaml/schema.ts b/encoding/yaml/_util/schema.ts similarity index 100% rename from encoding/_yaml/schema.ts rename to encoding/yaml/_util/schema.ts diff --git a/encoding/_yaml/schema/core.ts b/encoding/yaml/_util/schema/core.ts similarity index 100% rename from encoding/_yaml/schema/core.ts rename to encoding/yaml/_util/schema/core.ts diff --git a/encoding/_yaml/schema/default.ts b/encoding/yaml/_util/schema/default.ts similarity index 100% rename from encoding/_yaml/schema/default.ts rename to encoding/yaml/_util/schema/default.ts diff --git a/encoding/_yaml/schema/extended.ts b/encoding/yaml/_util/schema/extended.ts similarity index 93% rename from encoding/_yaml/schema/extended.ts rename to encoding/yaml/_util/schema/extended.ts index ada85602a0bb..7d0149755bd2 100644 --- a/encoding/_yaml/schema/extended.ts +++ b/encoding/yaml/_util/schema/extended.ts @@ -14,7 +14,7 @@ import { def } from "./default.ts"; * import { * EXTENDED_SCHEMA, * parse, - * } from "https://deno.land/std@$STD_VERSION/encoding/yaml.ts"; + * } from "https://deno.land/std@$STD_VERSION/encoding/yaml/mod.ts"; * * const data = parse( * ` diff --git a/encoding/_yaml/schema/failsafe.ts b/encoding/yaml/_util/schema/failsafe.ts similarity index 100% rename from encoding/_yaml/schema/failsafe.ts rename to encoding/yaml/_util/schema/failsafe.ts diff --git a/encoding/_yaml/schema/json.ts b/encoding/yaml/_util/schema/json.ts similarity index 100% rename from encoding/_yaml/schema/json.ts rename to encoding/yaml/_util/schema/json.ts diff --git a/encoding/_yaml/schema/mod.ts b/encoding/yaml/_util/schema/mod.ts similarity index 100% rename from encoding/_yaml/schema/mod.ts rename to encoding/yaml/_util/schema/mod.ts diff --git a/encoding/_yaml/state.ts b/encoding/yaml/_util/state.ts similarity index 100% rename from encoding/_yaml/state.ts rename to encoding/yaml/_util/state.ts diff --git a/encoding/_yaml/stringify.ts b/encoding/yaml/_util/stringify.ts similarity index 100% rename from encoding/_yaml/stringify.ts rename to encoding/yaml/_util/stringify.ts diff --git a/encoding/_yaml/stringify_test.ts b/encoding/yaml/_util/stringify_test.ts similarity index 97% rename from encoding/_yaml/stringify_test.ts rename to encoding/yaml/_util/stringify_test.ts index 3065cd9892d3..943613862d2a 100644 --- a/encoding/_yaml/stringify_test.ts +++ b/encoding/yaml/_util/stringify_test.ts @@ -3,7 +3,7 @@ // Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license. // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import { assertEquals, assertThrows } from "../../testing/asserts.ts"; +import { assertEquals, assertThrows } from "../../../testing/asserts.ts"; import { stringify } from "./stringify.ts"; import { YAMLError } from "./error.ts"; import { DEFAULT_SCHEMA, EXTENDED_SCHEMA } from "./schema/mod.ts"; diff --git a/encoding/_yaml/type.ts b/encoding/yaml/_util/type.ts similarity index 100% rename from encoding/_yaml/type.ts rename to encoding/yaml/_util/type.ts diff --git a/encoding/_yaml/type/binary.ts b/encoding/yaml/_util/type/binary.ts similarity index 98% rename from encoding/_yaml/type/binary.ts rename to encoding/yaml/_util/type/binary.ts index 67f7a88a6c22..680c7b9ddd4b 100644 --- a/encoding/_yaml/type/binary.ts +++ b/encoding/yaml/_util/type/binary.ts @@ -4,7 +4,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. import { Type } from "../type.ts"; import type { Any } from "../utils.ts"; -import { Buffer } from "../../../io/buffer.ts"; +import { Buffer } from "../../../../io/buffer.ts"; // [ 64, 65, 66 ] -> [ padding, CR, LF ] const BASE64_MAP = diff --git a/encoding/_yaml/type/bool.ts b/encoding/yaml/_util/type/bool.ts similarity index 100% rename from encoding/_yaml/type/bool.ts rename to encoding/yaml/_util/type/bool.ts diff --git a/encoding/_yaml/type/float.ts b/encoding/yaml/_util/type/float.ts similarity index 100% rename from encoding/_yaml/type/float.ts rename to encoding/yaml/_util/type/float.ts diff --git a/encoding/_yaml/type/function.ts b/encoding/yaml/_util/type/function.ts similarity index 100% rename from encoding/_yaml/type/function.ts rename to encoding/yaml/_util/type/function.ts diff --git a/encoding/_yaml/type/int.ts b/encoding/yaml/_util/type/int.ts similarity index 100% rename from encoding/_yaml/type/int.ts rename to encoding/yaml/_util/type/int.ts diff --git a/encoding/_yaml/type/map.ts b/encoding/yaml/_util/type/map.ts similarity index 100% rename from encoding/_yaml/type/map.ts rename to encoding/yaml/_util/type/map.ts diff --git a/encoding/_yaml/type/merge.ts b/encoding/yaml/_util/type/merge.ts similarity index 100% rename from encoding/_yaml/type/merge.ts rename to encoding/yaml/_util/type/merge.ts diff --git a/encoding/_yaml/type/mod.ts b/encoding/yaml/_util/type/mod.ts similarity index 100% rename from encoding/_yaml/type/mod.ts rename to encoding/yaml/_util/type/mod.ts diff --git a/encoding/_yaml/type/nil.ts b/encoding/yaml/_util/type/nil.ts similarity index 100% rename from encoding/_yaml/type/nil.ts rename to encoding/yaml/_util/type/nil.ts diff --git a/encoding/_yaml/type/omap.ts b/encoding/yaml/_util/type/omap.ts similarity index 100% rename from encoding/_yaml/type/omap.ts rename to encoding/yaml/_util/type/omap.ts diff --git a/encoding/_yaml/type/pairs.ts b/encoding/yaml/_util/type/pairs.ts similarity index 100% rename from encoding/_yaml/type/pairs.ts rename to encoding/yaml/_util/type/pairs.ts diff --git a/encoding/_yaml/type/regexp.ts b/encoding/yaml/_util/type/regexp.ts similarity index 100% rename from encoding/_yaml/type/regexp.ts rename to encoding/yaml/_util/type/regexp.ts diff --git a/encoding/_yaml/type/seq.ts b/encoding/yaml/_util/type/seq.ts similarity index 100% rename from encoding/_yaml/type/seq.ts rename to encoding/yaml/_util/type/seq.ts diff --git a/encoding/_yaml/type/set.ts b/encoding/yaml/_util/type/set.ts similarity index 100% rename from encoding/_yaml/type/set.ts rename to encoding/yaml/_util/type/set.ts diff --git a/encoding/_yaml/type/str.ts b/encoding/yaml/_util/type/str.ts similarity index 100% rename from encoding/_yaml/type/str.ts rename to encoding/yaml/_util/type/str.ts diff --git a/encoding/_yaml/type/timestamp.ts b/encoding/yaml/_util/type/timestamp.ts similarity index 100% rename from encoding/_yaml/type/timestamp.ts rename to encoding/yaml/_util/type/timestamp.ts diff --git a/encoding/_yaml/type/undefined.ts b/encoding/yaml/_util/type/undefined.ts similarity index 100% rename from encoding/_yaml/type/undefined.ts rename to encoding/yaml/_util/type/undefined.ts diff --git a/encoding/_yaml/utils.ts b/encoding/yaml/_util/utils.ts similarity index 100% rename from encoding/_yaml/utils.ts rename to encoding/yaml/_util/utils.ts diff --git a/encoding/yaml/mod.ts b/encoding/yaml/mod.ts new file mode 100644 index 000000000000..3831d1c752d6 --- /dev/null +++ b/encoding/yaml/mod.ts @@ -0,0 +1,62 @@ +// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license. +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. + +/** + * {@linkcode parse} and {@linkcode stringify} for handling + * [YAML](https://yaml.org/) encoded data. + * + * Ported from + * [js-yaml v3.13.1](https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da) + * + * If your YAML contains multiple documents in it, you can use {@linkcode parseAll} for + * handling it. + * + * To handle `regexp`, and `undefined` types, use {@linkcode EXTENDED_SCHEMA}. + * You can also use custom types by extending schemas. + * + * ## :warning: Limitations + * - `binary` type is currently not stable. + * + * For further examples see https://github.com/nodeca/js-yaml/tree/master/examples. + * @example + * ```ts + * import { + * parse, + * stringify, + * } from "https://deno.land/std@$STD_VERSION/encoding/yaml/mod.ts"; + * + * const data = parse(` + * foo: bar + * baz: + * - qux + * - quux + * `); + * console.log(data); + * // => { foo: "bar", baz: [ "qux", "quux" ] } + * + * const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] }); + * console.log(yaml); + * // => + * // foo: bar + * // baz: + * // - qux + * // - quux + * ``` + * + * @module + */ + +export type { ParseOptions } from "./_util/parse.ts"; +export { parse, parseAll } from "./_util/parse.ts"; +export type { DumpOptions as StringifyOptions } from "./_util/stringify.ts"; +export { stringify } from "./_util/stringify.ts"; +export type { SchemaDefinition } from "./_util/schema.ts"; +export { Type } from "./_util/type.ts"; +export type { KindType, RepresentFn, StyleVariant } from "./_util/type.ts"; +export { + CORE_SCHEMA, + DEFAULT_SCHEMA, + EXTENDED_SCHEMA, + FAILSAFE_SCHEMA, + JSON_SCHEMA, +} from "./_util/schema/mod.ts"; diff --git a/encoding/yaml_test.ts b/encoding/yaml/mod_test.ts similarity index 51% rename from encoding/yaml_test.ts rename to encoding/yaml/mod_test.ts index d13b93786980..cea1cd4b3949 100644 --- a/encoding/yaml_test.ts +++ b/encoding/yaml/mod_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. -import "./_yaml/parse_test.ts"; -import "./_yaml/stringify_test.ts"; +import "./_util/parse_test.ts"; +import "./_util/stringify_test.ts"; // Type check. -import "./yaml.ts"; +import "./mod.ts";