MCPcopy Create free account
hub / github.com/Effect-TS/effect / parseDocumentContent

Method parseDocumentContent

packages/effect/src/encoding/Yaml.ts:1063–1084  ·  view source on GitHub ↗
(start: Line)

Source from the content-addressed store, hash-verified

1061 }
1062
1063 private parseDocumentContent(start: Line): unknown {
1064 if (isDocumentStart(start)) {
1065 // Strip the comment after the marker, so quotes and flow openers are read as token starts.
1066 const rest = start.raw.slice(3).replace(/^[ \t]+/, "")
1067 const comment = findIndicator(rest, "#")
1068 const content = comment === -1 ? rest : trimWhiteEnd(rest.slice(0, comment))
1069 if (content.length > 0) {
1070 // Plain and flow scalars end at a comment flagged on their line. The marker hid
1071 // quotes from the scan that set the flag, so take it from this scan of the content.
1072 this.lines[this.index - 1] = { ...start, comment: comment !== -1 }
1073 // Block collections start on the line after the marker.
1074 if (isSequenceEntry(content) || mappingSeparator(content) !== -1) {
1075 this.fail(start, "Block collections cannot start on the document start line")
1076 }
1077 return this.parseNodeValue(content, -1)
1078 }
1079 }
1080 this.skipIgnored()
1081 const line = this.lineAt(this.index)
1082 if (line === undefined) return null
1083 return this.parseNode(line.indent)
1084 }
1085
1086 // `allowIndentless` is set for a mapping value, whose block sequence may sit at the mapping's
1087 // indentation (YAML 1.2.2 §8.2.1), also after node properties on their own lines.

Callers 1

parseDocumentMethod · 0.95

Calls 12

failMethod · 0.95
parseNodeValueMethod · 0.95
skipIgnoredMethod · 0.95
lineAtMethod · 0.95
parseNodeMethod · 0.95
isDocumentStartFunction · 0.85
findIndicatorFunction · 0.85
trimWhiteEndFunction · 0.85
isSequenceEntryFunction · 0.85
mappingSeparatorFunction · 0.85
sliceMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected