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

feat(AST): incorporate Presentation info model into YAML #109

Merged
merged 1 commit into from
Sep 29, 2020
Merged
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
7 changes: 4 additions & 3 deletions apidom/packages/apidom-ast/src/nodes/yaml/YamlKeyValuePair.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import stampit from 'stampit';
import YamlNode from './YamlNode';

interface YamlKeyValuePair extends YamlNode {
import Node from '../../Node';

interface YamlKeyValuePair extends Node {
type: 'keyValuePair';
}

const YamlKeyValuePair: stampit.Stamp<YamlKeyValuePair> = stampit(YamlNode, {
const YamlKeyValuePair: stampit.Stamp<YamlKeyValuePair> = stampit(Node, {
statics: {
type: 'keyValuePair',
},
Expand Down
9 changes: 8 additions & 1 deletion apidom/packages/apidom-ast/src/nodes/yaml/YamlNode.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
import stampit from 'stampit';

import Node from '../../Node';
import { YamlStyle, YamlStyleGroup } from './YamlStyle';

interface YamlNode extends Node {
content: unknown | null;
anchor: unknown | null;
tag: unknown | null;
style: YamlStyle;
styleGroup: YamlStyleGroup;
}

const YamlNode: stampit.Stamp<YamlNode> = stampit(Node, {
props: {
content: null,
anchor: null,
tag: null,
style: null,
styleGroup: null,
},
init({ content = null, anchor = null, tag = null } = {}) {
init({ content = null, anchor = null, tag = null, style = null, styleGroup = null } = {}) {
this.content = content;
this.anchor = anchor;
this.tag = tag;
this.style = style;
this.styleGroup = styleGroup;
},
});

Expand Down
4 changes: 4 additions & 0 deletions apidom/packages/apidom-ast/src/nodes/yaml/YamlScalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import YamlNode from './YamlNode';

interface YamlScalar extends YamlNode {
type: 'scalar';
format: string | null;
content: string | null;
}

const YamlScalar: stampit.Stamp<YamlScalar> = stampit(YamlNode, {
statics: {
type: 'scalar',
},
init({ format = null } = {}) {
this.format = format;
},
});

export default YamlScalar;
16 changes: 16 additions & 0 deletions apidom/packages/apidom-ast/src/nodes/yaml/YamlStyle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export enum YamlStyle {
Plain = 'Plain',
SingleQuoted = 'SingleQuoted',
DoubleQuoted = 'DoubleQuoted',
Literal = 'Literal',
Folded = 'Folded',
Explicit = 'Explicit',
SinglePair = 'SinglePair',
NextLine = 'NextLine',
InLine = 'InLine',
}

export enum YamlStyleGroup {
Flow = 'Flow',
Block = 'Block',
}