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

gherkin-js: Reverse GherkinDocument back to Feature #299

Closed
mlapeyre3 opened this Issue Nov 5, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@mlapeyre3

mlapeyre3 commented Nov 5, 2017

Summary

Hi there, I am using the gherkin library to parse a .feature file into a GherkinDocument.

const Gherkin = require('gherkin');
const parser = new Gherkin.Parser();
var gherkinDocument = parser.parse(feature);

I was wondering if there is a way to go back from a GherkinDocument object to a .feature string?

Expected Behavior

Something like:

var feature = parser.getFeature(GherkinDocument);

Current Behavior

I did not find any methods like this in the code.

Context & Motivation

It would be super nice to handle a getFeature() method. It's easier to handle the json-formatted GherkinDocument than a pure string like a .feature file.

Thanks !

@aslakhellesoy

This comment has been minimized.

Contributor

aslakhellesoy commented Nov 5, 2017

I'd like to know in what this context this would be useful, and how this would be better than just reading the source from disk.

@mlapeyre3

This comment has been minimized.

mlapeyre3 commented Nov 6, 2017

Hi @aslakhellesoy ! Ok let me explain a bit more.

I am using

const Gherkin = require('gherkin');
const parser = new Gherkin.Parser();
var gherkinDocument = parser.parse(feature);

to parse a .feature file on server side and respond to my client application with a json-formatted GherkinDocument.

The client application can easily handle the Feature as a json object and manipulate the properties of the document (for display, editing, ...).

Now, let's say my application has an interface to add/remove tags of a given Scenario, and a button to export a .feature file back from the GherkinDocument.

It's easy to add the tag in the tags: [] property of the Scenario. However, I want to be able to format the GherkinDocument back to a .feature string so that the user is able to download a new .feature file.

I found https://www.npmjs.com/package/gherkin-assembler to fulfill my need but I have not tested it yet.

@stale

This comment has been minimized.

stale bot commented Feb 17, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in a week if no further activity occurs.

@stale stale bot added the Stale label Feb 17, 2018

@aslakhellesoy

This comment has been minimized.

Contributor

aslakhellesoy commented Feb 17, 2018

@mlapeyre3 is there anything missing from gherkin-assembler? If not I think we can close this issue.

@stale stale bot removed the Stale label Feb 17, 2018

@mlapeyre3

This comment has been minimized.

mlapeyre3 commented Feb 19, 2018

HI @aslakhellesoy, sorry I did not follow-up my latest post.
https://www.npmjs.com/package/gherkin-assembler did the job so you can close this issue :)

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