cucumber / gherkin

A parser and compiler for the Gherkin language.
MIT License
188 stars 62 forks source link

Reverse GherkinDocument back to Feature #131

Closed jdavidrsantos closed 1 year ago

jdavidrsantos commented 1 year ago

Hi there, I am using the gherkin library to parse a .feature file into a GherkinDocument. // JavaScript var Gherkin = require('@cucumber/gherkin') var Messages = require('@cucumber/messages')

var uuidFn = Messages.IdGenerator.uuid() var builder = new Gherkin.AstBuilder(uuidFn) var matcher = new Gherkin.GherkinClassicTokenMatcher() // or Gherkin.GherkinInMarkdownTokenMatcher()

var parser = new Gherkin.Parser(builder, matcher) var gherkinDocument = parser.parse('Feature: ...') var pickles = Gherkin.compile(gherkinDocument, 'uri_of_the_feature.feature', uuidFn)

I'll like to be able to save the file ast back as a feature but I can't find any function that allows me to do so.

mpkorstanje commented 1 year ago

You might find some useful code in https://github.com/cucumber/gherkin-utils