Initial checkin

This commit is contained in:
Justin Greywolf
2019-11-25 17:15:57 -08:00
parent 4ff5c3b455
commit b57492c1c6
5 changed files with 120 additions and 44 deletions

View File

@@ -1,8 +0,0 @@
{
"typescript.format.enable": false,
"typescript.reportStyleChecksAsWarnings": false,
"typescript.validate.enable": false,
"javascript.validate.enable": false,
"editor.formatOnSave": false,
"editor.snippetSuggestions": "top"
}

View File

@@ -190,7 +190,7 @@ describe('Flowcart', () => {
);
});
it('9: should render subgraphs with a title startign with a digit', () => {
it('9: should render subgraphs with a title starting with a digit', () => {
imgSnapshotTest(
`
graph TB
@@ -237,7 +237,7 @@ describe('Flowcart', () => {
);
});
it('11: should render a flowchart with ling sames and class definitoins', () => {
it('11: should render a flowchart with long names and class definitions', () => {
imgSnapshotTest(
`graph LR
sid-B3655226-6C29-4D00-B685-3D5C734DC7E1["

View File

@@ -297,5 +297,100 @@ describe('class diagram, ', function() {
expect(testClass.methods[0]).toBe('test()');
expect(testClass.methods[1]).toBe('foo()');
});
it('should handle a comment', function () {
const str =
'classDiagram\n' +
'%% Comment \n' +
'class Class1 {\n' +
'int : test\n' +
'string : foo\n' +
'test()\n' +
'foo()\n' +
'}';
parser.parse(str);
});
// it('should handle comments at the start', function () {
// const str =
// '%% Comment\n' +
// 'class Class1 {\n' +
// 'int : test\n' +
// 'string : foo\n' +
// 'test()\n' +
// 'foo()\n' +
// '}';
// parser.parse(str);
// });
// it('should handle comments at the end', function () {
// const str =
// 'classDiagram\n' +
// 'class Class1 {\n' +
// 'int : test\n' +
// 'string : foo\n' +
// 'test()\n' +
// 'foo()\n' +
// '\n}' +
// '%% Comment\n';
// parser.parse(str);
// });
// it('should handle comments at the end no trailing newline', function () {
// const str =
// 'class Class1 {\n' +
// 'int : test\n' +
// 'string : foo\n' +
// 'test()\n' +
// 'foo()\n' +
// '}\n' +
// '%% Comment';
// parser.parse(str);
// });
// it('should handle comments at the end many trailing newlines', function () {
// const str =
// 'classDiagram\n' +
// '%% Comment\n\n\n\n\n' +
// 'class Class1 {\n' +
// 'int : test\n' +
// 'string : foo\n' +
// 'test()\n' +
// 'foo()\n' +
// '}';
// parser.parse(str);
// });
// it('should handle a comment with blank rows in-between', function () {
// const str =
// 'classDiagram\n\n\n' +
// '%% Comment\n\n' +
// 'class Class1 {\n' +
// 'int : test\n' +
// 'string : foo\n' +
// 'test()\n' +
// 'foo()\n' +
// '}';
// parser.parse(str);
// });
// it('should handle a comment with mermaid class diagram code in them', function () {
// const str =
// 'classDiagram\n' +
// '%% Comment Class01 <|-- Class02\n' +
// 'class Class1 {\n' +
// 'int : test\n' +
// 'string : foo\n' +
// 'test()\n' +
// 'foo()\n' +
// '}';
// parser.parse(str);
//});
});
});

View File

@@ -27,7 +27,7 @@ describe('[Comments] when parsing', () => {
expect(edges[0].text).toBe('');
});
it('should handle comments a at the start', function() {
it('should handle comments at the start', function() {
const res = flow.parser.parse('%% Comment\ngraph TD;\n A-->B;');
const vert = flow.parser.yy.getVertices();

View File

@@ -460,13 +460,6 @@ text: textToken
commentText: commentToken
{$$=$1;}
| commentText commentToken
{$$=$1+''+$2;}
;
keywords
: STYLE | LINKSTYLE | CLASSDEF | CLASS | CLICK | GRAPH | DIR | subgraph | end | DOWN | UP;
@@ -516,8 +509,6 @@ linkStyleStatement
{$$ = $1;yy.updateLinkInterpolate($3,$7);}
;
commentStatement: PCT PCT commentText;
numList: NUM
{$$ = [$1]}
| numList COMMA NUM
@@ -539,8 +530,6 @@ styleComponent: ALPHA | COLON | MINUS | NUM | UNIT | SPACE | HEX | BRKT | DOT |
/* Token lists */
commentToken : textToken | graphCodeTokens ;
textToken : textNoTagsToken | TAGSTART | TAGEND | '==' | '--' | PCT | DEFAULT;
textNoTagsToken: alphaNumToken | SPACE | MINUS | keywords ;