This repository has been archived by the owner on May 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Package dist/gherkin.js with license. Should be AMD compatible. Example.
- Loading branch information
1 parent
9138a76
commit 55d2419
Showing
6 changed files
with
70 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This is a minimal example demonstrating Gherkin in the browser. | ||
Edit a feature file, see the AST below. | ||
|
||
To run the example, run `make dist/gherkin.js` from the `javascript` directory. | ||
Then open `index.html` in a browser and type in the text area. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var input = document.getElementById('input'); | ||
var output = document.getElementById('output'); | ||
var parser = new Gherkin.Parser(); | ||
|
||
function parse() { | ||
console.log('parsing'); | ||
var result; | ||
try { | ||
var builder = new Gherkin.AstBuilder(); | ||
parser.stopAtFirstError = false; | ||
|
||
var scanner = new Gherkin.TokenScanner(input.value); | ||
var ast = parser.parse(scanner, builder, new Gherkin.TokenMatcher()); | ||
result = JSON.stringify(ast, null, 2); | ||
} catch (e) { | ||
result = e.message; | ||
} | ||
output.innerText = result; | ||
} | ||
|
||
input.onkeyup = function () { | ||
parse(); | ||
}; | ||
|
||
parse(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
</head> | ||
|
||
<body> | ||
<textarea id="input" cols="30" rows="10">Feature: Hello</textarea> | ||
<br> | ||
<pre id="output"></pre> | ||
<script src="../dist/gherkin.js"></script> | ||
<script src="demo.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
module.exports = { | ||
Parser: require('./lib/gherkin/parser'), | ||
TokenScanner: require('./lib/gherkin/token_scanner'), | ||
TokenMatcher: require('./lib/gherkin/token_matcher'), | ||
AstBuilder: require('./lib/gherkin/ast_builder') | ||
}; | ||
(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module. | ||
define([], factory); | ||
} else if (typeof window === 'object') { | ||
// Browser globals (root is window) | ||
window.Gherkin = factory(); | ||
} else { | ||
// Node.js/IO.js | ||
module.exports = factory(); | ||
} | ||
}(this, function () { | ||
return { | ||
Parser: require('./lib/gherkin/parser'), | ||
TokenScanner: require('./lib/gherkin/token_scanner'), | ||
TokenMatcher: require('./lib/gherkin/token_matcher'), | ||
AstBuilder: require('./lib/gherkin/ast_builder') | ||
}; | ||
})); |