From 16f3338b3d1a3af573a764d4fe89fce7d65d4cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20W=C3=BCrtz?= Date: Sun, 7 Jul 2019 16:28:31 -0300 Subject: [PATCH] feat(gantt.jison): update parser to accept a inclusive end date arg if a line contains inclusiveEndDates then it will toggle the chart to use inclusive end dates --- src/diagrams/gantt/parser/gantt.jison | 8 +++++--- src/diagrams/gantt/parser/gantt.spec.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/diagrams/gantt/parser/gantt.jison b/src/diagrams/gantt/parser/gantt.jison index d28a79d97..ea76b59a1 100644 --- a/src/diagrams/gantt/parser/gantt.jison +++ b/src/diagrams/gantt/parser/gantt.jison @@ -55,6 +55,7 @@ that id. "gantt" return 'gantt'; "dateFormat"\s[^#\n;]+ return 'dateFormat'; +"inclusiveEndDates" return 'inclusiveEndDates'; "axisFormat"\s[^#\n;]+ return 'axisFormat'; "excludes"\s[^#\n;]+ return 'excludes'; \d\d\d\d"-"\d\d"-"\d\d return 'date'; @@ -91,9 +92,10 @@ line ; statement - : 'dateFormat' {yy.setDateFormat($1.substr(11));$$=$1.substr(11);} - | 'axisFormat' {yy.setAxisFormat($1.substr(11));$$=$1.substr(11);} - | 'excludes' {yy.setExcludes($1.substr(9));$$=$1.substr(9);} + : dateFormat {yy.setDateFormat($1.substr(11));$$=$1.substr(11);} + | inclusiveEndDates {yy.enableInclusiveEndDates();$$=$1.substr(18);} + | axisFormat {yy.setAxisFormat($1.substr(11));$$=$1.substr(11);} + | excludes {yy.setExcludes($1.substr(9));$$=$1.substr(9);} | title {yy.setTitle($1.substr(6));$$=$1.substr(6);} | section {yy.addSection($1.substr(8));$$=$1.substr(8);} | clickStatement diff --git a/src/diagrams/gantt/parser/gantt.spec.js b/src/diagrams/gantt/parser/gantt.spec.js index 1a066b941..c6d8af285 100644 --- a/src/diagrams/gantt/parser/gantt.spec.js +++ b/src/diagrams/gantt/parser/gantt.spec.js @@ -15,8 +15,8 @@ describe('when parsing a gantt diagram it', function () { parser.parse(str) }) - it('should handle a dateFormat definition with inclusivity specified', function () { - const str = 'gantt\ndateFormat yyyy-mm-dd inclusive' + it('should handle a inclusive end date definition', function () { + const str = 'gantt\ndateFormat yyyy-mm-dd\ninclusiveEndDates' parser.parse(str) })