Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(encoding/yaml): unified dir and move to single-export files #3025

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion encoding/front_matter/any.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion encoding/front_matter/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function _extract<T>(
* ```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 });
Expand Down
2 changes: 1 addition & 1 deletion encoding/front_matter/mod_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion encoding/front_matter/yaml.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
62 changes: 2 additions & 60 deletions encoding/yaml.ts
Original file line number Diff line number Diff line change
@@ -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";
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down
Original file line number Diff line number Diff line change
@@ -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`);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion encoding/_yaml/parse.ts → encoding/yaml/_util/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(`
* ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
* `
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
62 changes: 62 additions & 0 deletions encoding/yaml/mod.ts
Original file line number Diff line number Diff line change
@@ -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";
6 changes: 3 additions & 3 deletions encoding/yaml_test.ts → encoding/yaml/mod_test.ts
Original file line number Diff line number Diff line change
@@ -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";