Skip to content

Commit

Permalink
Drop Document method listNonDefaultTags()
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The public method is no longer available, as its
internal use for it is being refactored to StreamDirectives. An
alternative pattern will need to be documented for any current users,
once the visitor API is available to use as a base for it. (#190)
  • Loading branch information
eemeli committed Jan 2, 2021
1 parent 1472244 commit 5ff783d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion docs/04_documents.md
Expand Up @@ -102,7 +102,6 @@ During stringification, a document with a true-ish `version` value will include
| ------------------------------------------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| createNode(value, options?) | `Node` | Recursively wrap any input with appropriate `Node` containers. See [Creating Nodes](#creating-nodes) for more information. |
| createPair(key, value, options?) | `Pair` | Recursively wrap `key` and `value` into a `Pair` object. See [Creating Nodes](#creating-nodes) for more information. |
| listNonDefaultTags() | `string[]` | List the tags used in the document that are not in the default `tag:yaml.org,2002:` namespace. |
| parse(cst) | `Document` | Parse a CST into this document. Mostly an internal method, modifying the document according to the contents of the parsed `cst`. Calling this multiple times on a Document is not recommended. |
| setSchema(id?, customTags?) | `void` | Set the schema used by the document. `id` may either be a YAML version, or the identifier of a YAML 1.2 schema; if set, `customTags` should have the same shape as the similarly-named option. |
| setTagPrefix(handle, prefix) | `void` | Set `handle` as a shorthand string for the `prefix` tag namespace. |
Expand Down
6 changes: 1 addition & 5 deletions index.d.ts
Expand Up @@ -283,11 +283,7 @@ export class Document extends Collection {
* `Scalar` objects.
*/
createPair(key: any, value: any, options?: { wrapScalars?: boolean }): Pair
/**
* List the tags used in the document that are not in the default
* `tag:yaml.org,2002:` namespace.
*/
listNonDefaultTags(): string[]

/** Parse a CST into this document */
parse(cst: CST.Document): this
/**
Expand Down
6 changes: 1 addition & 5 deletions src/doc/Document.d.ts
Expand Up @@ -87,11 +87,7 @@ export class Document extends Collection {
* `Scalar` objects.
*/
createPair(key: any, value: any, options?: { wrapScalars?: boolean }): Pair
/**
* List the tags used in the document that are not in the default
* `tag:yaml.org,2002:` namespace.
*/
listNonDefaultTags(): string[]

/** Parse a CST into this document */
parse(cst: CST.Document): this
/**
Expand Down
10 changes: 3 additions & 7 deletions src/doc/Document.js
Expand Up @@ -239,12 +239,6 @@ export class Document {
return this
}

listNonDefaultTags() {
return listTagNames(this.contents).filter(
t => t.indexOf(defaultTagPrefix) !== 0
)
}

setTagPrefix(handle, prefix) {
if (handle[0] !== '!' || handle[handle.length - 1] !== '!')
throw new Error('Handle must start and end with !')
Expand Down Expand Up @@ -306,7 +300,9 @@ export class Document {
lines.push(vd)
hasDirectives = true
}
const tagNames = this.listNonDefaultTags()
const tagNames = listTagNames(this.contents).filter(
t => t.indexOf(defaultTagPrefix) !== 0
)
this.tagPrefixes.forEach(({ handle, prefix }) => {
if (tagNames.some(t => t.indexOf(prefix) === 0)) {
lines.push(`%TAG ${handle} ${prefix}`)
Expand Down

0 comments on commit 5ff783d

Please sign in to comment.