diff --git a/src/ast/from_events.ts b/src/ast/from_events.ts index f06d419f..a802faa4 100644 --- a/src/ast/from_events.ts +++ b/src/ast/from_events.ts @@ -54,6 +54,7 @@ interface MappingFrame { type Frame = DocumentFrame | SequenceFrame | MappingFrame +/** @category AST */ interface FromEventsOptions { source: string schema: Schema @@ -161,6 +162,7 @@ function addNode (state: FromEventsState, node: Node) { } } +/** @category AST */ function eventsToAst (events: Event[], options: FromEventsOptions): Document[] { const state: FromEventsState = { source: options.source, diff --git a/src/ast/from_js.ts b/src/ast/from_js.ts index 85c71176..eb776ccc 100644 --- a/src/ast/from_js.ts +++ b/src/ast/from_js.ts @@ -15,6 +15,7 @@ import { type MappingNode } from './nodes.ts' +/** @category AST */ interface FromJsOptions { noRefs?: boolean skipInvalid?: boolean @@ -151,6 +152,7 @@ function build (state: FromJsState, object: unknown): Node | typeof INVALID { // A JS value is one YAML document. An unrepresentable root becomes an empty // document, which the presenter renders as an empty string. +/** @category AST */ function jsToAst (input: unknown, schema: Schema, options: FromJsOptions = {}): Document[] { const state: FromJsState = { representTypes: buildRepresentTypes(schema), diff --git a/src/ast/nodes.ts b/src/ast/nodes.ts index dd505a25..f0d558cb 100644 --- a/src/ast/nodes.ts +++ b/src/ast/nodes.ts @@ -4,6 +4,7 @@ import { type DocumentDirective } from '../parser/events.ts' +/** @category Nodes */ class Style { tagged = false flow = false @@ -13,6 +14,7 @@ class Style { folded = false } +/** @category Nodes */ interface NodeBase { // YAML tag. Untagged nodes carry the semantic resolved tag; tagged nodes carry // the printable/verbatim tag spelling. @@ -27,32 +29,38 @@ interface NodeBase { blankBefore?: number } +/** @category Nodes */ interface ScalarNode extends NodeBase { kind: 'scalar' value: string } +/** @category Nodes */ interface SequenceNode extends NodeBase { kind: 'sequence' items: Node[] } +/** @category Nodes */ interface MappingNode extends NodeBase { kind: 'mapping' items: Array<{ key: Node, value: Node }> } +/** @category Nodes */ interface AliasNode extends NodeBase { kind: 'alias' // The anchor name this alias points at (`*name`). anchor: string } +/** @category Nodes */ type Node = ScalarNode | SequenceNode | MappingNode | AliasNode // The layer above `Node`: each document wraps one content node plus its own // markers/directives. Not a member of `Node` — the fields differ. Document // directives are ordered presentation data. +/** @category Nodes */ interface Document { contents: Node | null // null = empty document explicitStart?: boolean // print '---' diff --git a/src/ast/presenter.ts b/src/ast/presenter.ts index e73d7f9c..4d6c8622 100644 --- a/src/ast/presenter.ts +++ b/src/ast/presenter.ts @@ -57,6 +57,7 @@ ESCAPE_SEQUENCES[0xA0] = '\\_' ESCAPE_SEQUENCES[0x2028] = '\\L' ESCAPE_SEQUENCES[0x2029] = '\\P' +/** @category AST */ interface PresenterOptions { schema: Schema indent?: number @@ -976,6 +977,7 @@ function writeDocumentDirectives (doc: Document) { } // Documents → text, including the trailing newline. +/** @category AST */ function present (documents: Document[], options: PresenterOptions): string { const state = createPresenterState(options) let result = '' diff --git a/src/ast/visit.ts b/src/ast/visit.ts index 2afbca60..af3030bc 100644 --- a/src/ast/visit.ts +++ b/src/ast/visit.ts @@ -9,7 +9,9 @@ import { // Returned by a visitor to control the walk; anything else (incl. `undefined`) // descends as usual. +/** @category other */ const VISIT_BREAK = Symbol('visit:break') // stop the whole traversal +/** @category other */ const VISIT_SKIP = Symbol('visit:skip') // don't descend into this node's children type VisitControl = typeof VISIT_BREAK | typeof VISIT_SKIP | undefined | void @@ -17,12 +19,14 @@ type VisitControl = typeof VISIT_BREAK | typeof VISIT_SKIP | undefined | void // Traversal-derived position of the current node. Kept off the node itself: a // node may sit in several places (alias/dedup reuse), so depth/role belong to // the walk, not the node. `parent.kind` + `isKey` pin the exact slot. +/** @category AST */ interface VisitContext { depth: number // 0 = document content root parent: Node | null // enclosing sequence/mapping, null at the root isKey: boolean // node sits in a mapping key position } +/** @category AST */ type Visitor = (node: Node, ctx: VisitContext) => VisitControl // Returns `true` once `VISIT_BREAK` was seen, so callers can unwind the walk. @@ -51,6 +55,7 @@ function visitNode (node: Node, visitor: Visitor, ctx: VisitContext): boolean { } // Walk every node in the documents, calling `visitor` once per node (pre-order). +/** @category AST */ function visit (documents: Document[], visitor: Visitor): void { for (const doc of documents) { if (doc.contents && visitNode(doc.contents, visitor, { depth: 0, parent: null, isKey: false })) return diff --git a/src/parser/constructor.ts b/src/parser/constructor.ts index 89ab9c90..f4e3cc60 100644 --- a/src/parser/constructor.ts +++ b/src/parser/constructor.ts @@ -75,6 +75,7 @@ interface Anchor { isValueFinal: boolean } +/** @category Events */ interface ConstructorOptions { source: string filename?: string @@ -352,6 +353,7 @@ function storeAnchor ( return null } +/** @category Events */ function constructFromEvents (events: Event[], options: ConstructorOptions): unknown[] { const state: ConstructorState = { ...DEFAULT_CONSTRUCTOR_OPTIONS, diff --git a/src/parser/events.ts b/src/parser/events.ts index ab2b2e25..e65ec77b 100644 --- a/src/parser/events.ts +++ b/src/parser/events.ts @@ -1,18 +1,29 @@ +/** @category other */ const EVENT_DOCUMENT = 1 +/** @category other */ const EVENT_SEQUENCE = 2 +/** @category other */ const EVENT_MAPPING = 3 +/** @category other */ const EVENT_SCALAR = 4 +/** @category other */ const EVENT_ALIAS = 5 +/** @category other */ const EVENT_POP = 6 type EventType = typeof EVENT_DOCUMENT | typeof EVENT_SEQUENCE | typeof EVENT_MAPPING | typeof EVENT_SCALAR | typeof EVENT_ALIAS | typeof EVENT_POP +/** @category Nodes */ const SCALAR_STYLE_PLAIN = 1 +/** @category Nodes */ const SCALAR_STYLE_SINGLE_QUOTED = 2 +/** @category Nodes */ const SCALAR_STYLE_DOUBLE_QUOTED = 3 +/** @category Nodes */ const SCALAR_STYLE_LITERAL_BLOCK = 4 +/** @category Nodes */ const SCALAR_STYLE_FOLDED_BLOCK = 5 type ScalarStyle = @@ -20,25 +31,32 @@ type ScalarStyle = typeof SCALAR_STYLE_DOUBLE_QUOTED | typeof SCALAR_STYLE_LITERAL_BLOCK | typeof SCALAR_STYLE_FOLDED_BLOCK +/** @category Nodes */ const COLLECTION_STYLE_BLOCK = 1 +/** @category Nodes */ const COLLECTION_STYLE_FLOW = 2 type CollectionStyle = typeof COLLECTION_STYLE_BLOCK | typeof COLLECTION_STYLE_FLOW +/** @category Nodes */ const CHOMPING_CLIP = 1 +/** @category Nodes */ const CHOMPING_STRIP = 2 +/** @category Nodes */ const CHOMPING_KEEP = 3 type Chomping = typeof CHOMPING_CLIP | typeof CHOMPING_STRIP | typeof CHOMPING_KEEP +/** @category other */ type DocumentDirective = { kind: 'yaml', version: string } | { kind: 'tag', handle: string, prefix: string } type TagHandlers = Record +/** @category Events */ interface DocumentEvent { type: typeof EVENT_DOCUMENT explicitStart: boolean @@ -46,6 +64,7 @@ interface DocumentEvent { directives: DocumentDirective[] } +/** @category Events */ interface SequenceEvent { type: typeof EVENT_SEQUENCE start: number @@ -56,6 +75,7 @@ interface SequenceEvent { style: CollectionStyle } +/** @category Events */ interface MappingEvent { type: typeof EVENT_MAPPING start: number @@ -66,6 +86,7 @@ interface MappingEvent { style: CollectionStyle } +/** @category Events */ interface ScalarEvent { type: typeof EVENT_SCALAR valueStart: number @@ -80,16 +101,19 @@ interface ScalarEvent { fast: boolean } +/** @category Events */ interface AliasEvent { type: typeof EVENT_ALIAS anchorStart: number anchorEnd: number } +/** @category Events */ interface PopEvent { type: typeof EVENT_POP } +/** @category Events */ type Event = DocumentEvent | SequenceEvent | diff --git a/src/parser/parser.ts b/src/parser/parser.ts index a472395c..d56e557f 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -71,6 +71,7 @@ interface ParserSnapshot { eventsLength: number } +/** @category Events */ interface ParserOptions { filename?: string maxDepth?: number @@ -1423,6 +1424,7 @@ function readDocument (state: ParserState) { } } +/** @category Events */ function parseEvents (input: string, options: ParserOptions): Event[] { const length = input.length const state: ParserState = { diff --git a/src/parser/parser_scalar.ts b/src/parser/parser_scalar.ts index 773522e6..a0e5718c 100644 --- a/src/parser/parser_scalar.ts +++ b/src/parser/parser_scalar.ts @@ -281,6 +281,7 @@ function getBlockValue ( return result } +/** @category Events */ function getScalarValue (input: string, scalar: ScalarEvent): string { if (scalar.valueStart === NO_RANGE) return '' diff --git a/src/schema.ts b/src/schema.ts index 18c8b383..a3170031 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -77,6 +77,7 @@ function compileTags (tags: readonly TagDefinition[]) { return result } +/** @category Schema */ class Schema { readonly tags: readonly TagDefinition[] readonly implicitScalarTags: readonly ScalarTagDefinition[] @@ -165,12 +166,14 @@ class Schema { } } +/** @category Schema */ const FAILSAFE_SCHEMA = new Schema([ strTag, seqTag, mapTag ]) +/** @category Schema */ const JSON_SCHEMA = new Schema([ ...FAILSAFE_SCHEMA.tags, nullJsonTag, @@ -179,6 +182,7 @@ const JSON_SCHEMA = new Schema([ floatJsonTag ]) +/** @category Schema */ const CORE_SCHEMA = new Schema([ ...FAILSAFE_SCHEMA.tags, nullCoreTag, @@ -187,6 +191,7 @@ const CORE_SCHEMA = new Schema([ floatCoreTag ]) +/** @category Schema */ const YAML11_SCHEMA = new Schema([ ...FAILSAFE_SCHEMA.tags, nullYaml11Tag, diff --git a/src/tag.ts b/src/tag.ts index 151636e8..90d0484d 100644 --- a/src/tag.ts +++ b/src/tag.ts @@ -1,4 +1,6 @@ +/** @category other */ const NOT_RESOLVED: unique symbol = Symbol('NOT_RESOLVED') +/** @category other */ const MERGE_KEY: unique symbol = Symbol('MERGE_KEY') type ScalarRepresent = (data: any) => string @@ -8,6 +10,7 @@ type MappingRepresent = (data: any) => Map type IdentifyFn = (data: any) => boolean type RepresentTagNameFn = (data: any) => string +/** @category Tags */ interface ScalarTagDefinition { tagName: string nodeKind: 'scalar' @@ -28,6 +31,7 @@ interface ScalarTagDefinition { representTagName: RepresentTagNameFn | null } +/** @category Tags */ interface SequenceTagDefinition { tagName: string nodeKind: 'sequence' @@ -42,6 +46,7 @@ interface SequenceTagDefinition { representTagName: RepresentTagNameFn | null } +/** @category Tags */ interface MappingTagDefinition { tagName: string nodeKind: 'mapping' @@ -65,11 +70,13 @@ interface MappingTagDefinition { representTagName: RepresentTagNameFn | null } +/** @category Tags */ type TagDefinition = | ScalarTagDefinition | SequenceTagDefinition | MappingTagDefinition +/** @category Tags */ interface ScalarTagOptions { implicit?: boolean matchByTagPrefix?: boolean @@ -98,6 +105,7 @@ type RepresentOptions = representTagName?: RepresentTagNameFn | null }) +/** @category Tags */ type SequenceTagOptions = { matchByTagPrefix?: boolean create: SequenceTagDefinition['create'] @@ -105,6 +113,7 @@ type SequenceTagOptions = { finalize?: SequenceTagDefinition['finalize'] } & RepresentOptions, SequenceRepresent> +/** @category Tags */ type MappingTagOptions = { matchByTagPrefix?: boolean create: MappingTagDefinition['create'] @@ -115,6 +124,7 @@ type MappingTagOptions = { finalize?: MappingTagDefinition['finalize'] } & RepresentOptions, MappingRepresent> +/** @category Tags */ function defineScalarTag (tagName: string, options: ScalarTagOptions): ScalarTagDefinition { return { tagName, @@ -129,6 +139,7 @@ function defineScalarTag (tagName: string, options: ScalarTagOptions (tagName: string, options: SequenceTagOptions): SequenceTagDefinition { const carrierIsResult = options.finalize === undefined @@ -147,6 +158,7 @@ function defineSequenceTag (tagName: string, options: } } +/** @category Tags */ function defineMappingTag (tagName: string, options: MappingTagOptions): MappingTagDefinition { const carrierIsResult = options.finalize === undefined diff --git a/src/tag/mapping/legacy_map.ts b/src/tag/mapping/legacy_map.ts index 54c081e6..ecd9dc84 100644 --- a/src/tag/mapping/legacy_map.ts +++ b/src/tag/mapping/legacy_map.ts @@ -31,6 +31,7 @@ function normalizeKey (key: unknown): string | null { return String(key) } +/** @category Tags */ const legacyMapTag = defineMappingTag('tag:yaml.org,2002:map', { create: (): StringMapping => ({}), identify: isPlainObject, diff --git a/src/tag/mapping/map.ts b/src/tag/mapping/map.ts index 71622f06..0168e1ac 100644 --- a/src/tag/mapping/map.ts +++ b/src/tag/mapping/map.ts @@ -3,6 +3,7 @@ import { isPlainObject } from '../../common/object.ts' type StringMapping = Record +/** @category Tags */ const mapTag = defineMappingTag('tag:yaml.org,2002:map', { create: (): StringMapping => ({}), identify: isPlainObject, diff --git a/src/tag/mapping/real_map.ts b/src/tag/mapping/real_map.ts index 86cc452a..7ae67abb 100644 --- a/src/tag/mapping/real_map.ts +++ b/src/tag/mapping/real_map.ts @@ -6,6 +6,7 @@ type RealMapping = Map // A mapping represented as a real `Map`: keys keep their constructed type, // nothing is stringified. Drop-in replacement for the default `!!map` tag // (same tag name) — `CORE_SCHEMA.withTags(realMapTag)`. +/** @category Tags */ const realMapTag = defineMappingTag('tag:yaml.org,2002:map', { create: () => new Map(), addPair: (container: RealMapping, key, value) => { diff --git a/src/tag/mapping/set.ts b/src/tag/mapping/set.ts index 24ab86bd..40f45d2e 100644 --- a/src/tag/mapping/set.ts +++ b/src/tag/mapping/set.ts @@ -1,5 +1,6 @@ import { defineMappingTag } from '../../tag.ts' +/** @category Tags */ const setTag = defineMappingTag('tag:yaml.org,2002:set', { create: () => new Set(), identify: (data) => data instanceof Set, diff --git a/src/tag/scalar/binary.ts b/src/tag/scalar/binary.ts index 43a0d1d0..1cbb8195 100644 --- a/src/tag/scalar/binary.ts +++ b/src/tag/scalar/binary.ts @@ -23,6 +23,7 @@ function representYamlBinary (object: Uint8Array) { return btoa(binary) } +/** @category Tags */ const binaryTag = defineScalarTag('tag:yaml.org,2002:binary', { resolve: resolveYamlBinary, identify: (object) => Object.prototype.toString.call(object) === '[object Uint8Array]', diff --git a/src/tag/scalar/bool_core.ts b/src/tag/scalar/bool_core.ts index 8a686e56..d2db8d6e 100644 --- a/src/tag/scalar/bool_core.ts +++ b/src/tag/scalar/bool_core.ts @@ -3,6 +3,7 @@ import { defineScalarTag, NOT_RESOLVED } from '../../tag.ts' const TRUE_VALUES = ['true', 'True', 'TRUE'] const FALSE_VALUES = ['false', 'False', 'FALSE'] +/** @category Tags */ const boolCoreTag = defineScalarTag('tag:yaml.org,2002:bool', { implicit: true, // Superset of source.charAt(0) over all matched inputs: true/True/TRUE, false/False/FALSE. diff --git a/src/tag/scalar/bool_json.ts b/src/tag/scalar/bool_json.ts index e673b73c..c04a5c54 100644 --- a/src/tag/scalar/bool_json.ts +++ b/src/tag/scalar/bool_json.ts @@ -3,6 +3,7 @@ import { defineScalarTag, NOT_RESOLVED } from '../../tag.ts' const TRUE_VALUES = ['true'] const FALSE_VALUES = ['false'] +/** @category Tags */ const boolJsonTag = defineScalarTag('tag:yaml.org,2002:bool', { implicit: true, // Superset of source.charAt(0) over all matched inputs: true, false. diff --git a/src/tag/scalar/bool_yaml11.ts b/src/tag/scalar/bool_yaml11.ts index fc722d06..a6e21243 100644 --- a/src/tag/scalar/bool_yaml11.ts +++ b/src/tag/scalar/bool_yaml11.ts @@ -3,6 +3,7 @@ import { defineScalarTag, NOT_RESOLVED } from '../../tag.ts' const TRUE_VALUES = ['true', 'True', 'TRUE', 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON'] const FALSE_VALUES = ['false', 'False', 'FALSE', 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'] +/** @category Tags */ const boolYaml11Tag = defineScalarTag('tag:yaml.org,2002:bool', { implicit: true, // Superset of source.charAt(0) over all matched inputs. diff --git a/src/tag/scalar/float_core.ts b/src/tag/scalar/float_core.ts index b7a18312..566ae283 100644 --- a/src/tag/scalar/float_core.ts +++ b/src/tag/scalar/float_core.ts @@ -44,6 +44,7 @@ function representYamlFloat (object: number) { return /^[-+]?[0-9]+e/.test(result) ? result.replace('e', '.e') : result } +/** @category Tags */ const floatCoreTag = defineScalarTag('tag:yaml.org,2002:float', { implicit: true, // Superset of source.charAt(0) over all matched inputs: optional sign, '.', or digit diff --git a/src/tag/scalar/float_json.ts b/src/tag/scalar/float_json.ts index ad222630..cd37e65d 100644 --- a/src/tag/scalar/float_json.ts +++ b/src/tag/scalar/float_json.ts @@ -51,6 +51,7 @@ function representYamlFloat (object: number) { return /^[-+]?[0-9]+e/.test(result) ? result.replace('e', '.e') : result } +/** @category Tags */ const floatJsonTag = defineScalarTag('tag:yaml.org,2002:float', { implicit: true, // Superset of source.charAt(0) over all matched inputs: optional '-' or digit. diff --git a/src/tag/scalar/float_yaml11.ts b/src/tag/scalar/float_yaml11.ts index 6fd27e64..7d0eabb0 100644 --- a/src/tag/scalar/float_yaml11.ts +++ b/src/tag/scalar/float_yaml11.ts @@ -51,6 +51,7 @@ function representYamlFloat (object: number) { return /^[-+]?[0-9]+e/.test(result) ? result.replace('e', '.e') : result } +/** @category Tags */ const floatYaml11Tag = defineScalarTag('tag:yaml.org,2002:float', { implicit: true, // Superset of source.charAt(0) over all matched inputs: optional sign, '.', or digit diff --git a/src/tag/scalar/int_core.ts b/src/tag/scalar/int_core.ts index e097e8bf..53f54860 100644 --- a/src/tag/scalar/int_core.ts +++ b/src/tag/scalar/int_core.ts @@ -48,6 +48,7 @@ function resolveYamlInteger (source: string, isExplicit: boolean) { return Number.isFinite(result) ? result : NOT_RESOLVED } +/** @category Tags */ const intCoreTag = defineScalarTag('tag:yaml.org,2002:int', { implicit: true, // Superset of source.charAt(0) over all matched inputs: optional sign + decimal digit. diff --git a/src/tag/scalar/int_json.ts b/src/tag/scalar/int_json.ts index 393292c9..b7521fcc 100644 --- a/src/tag/scalar/int_json.ts +++ b/src/tag/scalar/int_json.ts @@ -43,6 +43,7 @@ function resolveYamlInteger (source: string, isExplicit: boolean) { return Number.isFinite(result) ? result : NOT_RESOLVED } +/** @category Tags */ const intJsonTag = defineScalarTag('tag:yaml.org,2002:int', { implicit: true, // Superset of source.charAt(0) over all matched inputs: optional '-' or digit. diff --git a/src/tag/scalar/int_yaml11.ts b/src/tag/scalar/int_yaml11.ts index a4c30326..2ce9a7c5 100644 --- a/src/tag/scalar/int_yaml11.ts +++ b/src/tag/scalar/int_yaml11.ts @@ -42,6 +42,7 @@ function resolveYamlInteger (source: string) { return Number.isFinite(result) ? result : NOT_RESOLVED } +/** @category Tags */ const intYaml11Tag = defineScalarTag('tag:yaml.org,2002:int', { implicit: true, // Superset of source.charAt(0) over all matched inputs: optional sign + decimal digit. diff --git a/src/tag/scalar/merge.ts b/src/tag/scalar/merge.ts index e8e374c4..1d49947b 100644 --- a/src/tag/scalar/merge.ts +++ b/src/tag/scalar/merge.ts @@ -1,5 +1,6 @@ import { defineScalarTag, MERGE_KEY, NOT_RESOLVED } from '../../tag.ts' +/** @category Tags */ const mergeTag = defineScalarTag('tag:yaml.org,2002:merge', { implicit: true, // source.charAt(0) over matched implicit inputs: '<' ('<<'). diff --git a/src/tag/scalar/null_core.ts b/src/tag/scalar/null_core.ts index c157e357..c23e0493 100644 --- a/src/tag/scalar/null_core.ts +++ b/src/tag/scalar/null_core.ts @@ -2,6 +2,7 @@ import { defineScalarTag, NOT_RESOLVED } from '../../tag.ts' const NULL_VALUES = ['', '~', 'null', 'Null', 'NULL'] +/** @category Tags */ const nullCoreTag = defineScalarTag('tag:yaml.org,2002:null', { implicit: true, // Superset of source.charAt(0) over all matched inputs: '' (empty), '~', 'null'/'Null'/'NULL'. diff --git a/src/tag/scalar/null_json.ts b/src/tag/scalar/null_json.ts index 203f4500..7c06c8ca 100644 --- a/src/tag/scalar/null_json.ts +++ b/src/tag/scalar/null_json.ts @@ -1,5 +1,6 @@ import { defineScalarTag, NOT_RESOLVED } from '../../tag.ts' +/** @category Tags */ const nullJsonTag = defineScalarTag('tag:yaml.org,2002:null', { implicit: true, // Superset of source.charAt(0) over all matched inputs: null. diff --git a/src/tag/scalar/null_yaml11.ts b/src/tag/scalar/null_yaml11.ts index 15f7012d..8c1b3e55 100644 --- a/src/tag/scalar/null_yaml11.ts +++ b/src/tag/scalar/null_yaml11.ts @@ -2,6 +2,7 @@ import { defineScalarTag, NOT_RESOLVED } from '../../tag.ts' const NULL_VALUES = ['', '~', 'null', 'Null', 'NULL'] +/** @category Tags */ const nullYaml11Tag = defineScalarTag('tag:yaml.org,2002:null', { implicit: true, // Superset of source.charAt(0) over all matched inputs: '' (empty), '~', 'null'/'Null'/'NULL'. diff --git a/src/tag/scalar/str.ts b/src/tag/scalar/str.ts index 75e392ab..6aa7495e 100644 --- a/src/tag/scalar/str.ts +++ b/src/tag/scalar/str.ts @@ -1,5 +1,6 @@ import { defineScalarTag } from '../../tag.ts' +/** @category Tags */ const strTag = defineScalarTag('tag:yaml.org,2002:str', { resolve: (source) => source, identify: (data) => typeof data === 'string' diff --git a/src/tag/scalar/timestamp.ts b/src/tag/scalar/timestamp.ts index 6758be42..d01d28b3 100644 --- a/src/tag/scalar/timestamp.ts +++ b/src/tag/scalar/timestamp.ts @@ -86,6 +86,7 @@ function resolveYamlTimestamp (source: string) { return date } +/** @category Tags */ const timestampTag = defineScalarTag('tag:yaml.org,2002:timestamp', { implicit: true, // Both patterns start with a 4-digit year, so source.charAt(0) is always a digit. diff --git a/src/tag/sequence/omap.ts b/src/tag/sequence/omap.ts index b12f4bd0..3f858da7 100644 --- a/src/tag/sequence/omap.ts +++ b/src/tag/sequence/omap.ts @@ -6,6 +6,7 @@ interface OmapCarrier { seen: Set } +/** @category Tags */ const omapTag = defineSequenceTag('tag:yaml.org,2002:omap', { create: (): OmapCarrier => ({ list: [], seen: new Set() }), addItem: (carrier, item) => { diff --git a/src/tag/sequence/pairs.ts b/src/tag/sequence/pairs.ts index 5d02656c..2be51b72 100644 --- a/src/tag/sequence/pairs.ts +++ b/src/tag/sequence/pairs.ts @@ -2,6 +2,7 @@ import { defineSequenceTag } from '../../tag.ts' type Pair = [unknown, unknown] +/** @category Tags */ const pairsTag = defineSequenceTag('tag:yaml.org,2002:pairs', { create: () => [] as Pair[], addItem: (container, item) => { diff --git a/src/tag/sequence/seq.ts b/src/tag/sequence/seq.ts index c07cb908..b0744c93 100644 --- a/src/tag/sequence/seq.ts +++ b/src/tag/sequence/seq.ts @@ -1,5 +1,6 @@ import { defineSequenceTag } from '../../tag.ts' +/** @category Tags */ const seqTag = defineSequenceTag('tag:yaml.org,2002:seq', { create: () => [] as unknown[], addItem: (container, item) => {