Skip to content

parser: preserve YAML front matter in specification files - #2890

Draft
Huruikagi wants to merge 2 commits into
getgauge:masterfrom
Huruikagi:feature/yaml-front-matter
Draft

parser: preserve YAML front matter in specification files#2890
Huruikagi wants to merge 2 commits into
getgauge:masterfrom
Huruikagi:feature/yaml-front-matter

Conversation

@Huruikagi

Copy link
Copy Markdown

Refs #2885

Summary

Adds support for preserving YAML Front Matter at the beginning of Gauge specification files.

The implementation does not parse or validate YAML. When the first line is ---, the lexer treats everything through the matching closing --- as opaque CommentKind items, then resumes normal Gauge parsing.

Behavior

---
id: login-success
owner: authentication-team
---

# Login

## Successful login

* Log in with valid credentials

The Front Matter is preserved by gauge format, while Gauge syntax inside the block is not interpreted.

Source line numbers for specifications, scenarios, and steps are also preserved.

Existing setext-style Scenario headings using --- outside Front Matter continue to work as before.

Compatibility note

This change also preserves ordinary comments that appear before the Spec heading in their original position.

Currently, the formatter moves such comments after the Spec heading. Since the proof-of-concept represents Front Matter as ordinary comments internally, preserving Front Matter also changes that existing formatter behavior.

Validation

Verified with:

go test -count=1 ./parser ./formatter
go run build/make.go --test --verbose

Both pass successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants