diff --git a/doc/src/main/asciidoc/index.adoc b/doc/src/main/asciidoc/index.adoc index c21f2fd..9856a87 100644 --- a/doc/src/main/asciidoc/index.adoc +++ b/doc/src/main/asciidoc/index.adoc @@ -71,7 +71,7 @@ Unzip `jsyntrax-XXX.zip` file to any convenient folder. `/bin` directory will co === Using JSyntrax -JSyntrax is a command line tool. You pass it an input specification file and it will generate a diagram in any of the supported output formats. +JSyntrax is a command line tool. You pass it an input specification file, and it will generate a diagram in any of the supported output formats. ---- usage: syntrax [--get-style] [-h] [-i ] [-o ] [-s ] [--scale @@ -113,7 +113,7 @@ Done! ==== Transparency -By default the images have a white background. If you want a transparent background pass the `+-t+` option. +By default, the images have a white background. If you want a transparent background pass the `+-t+` option. ==== Scaling @@ -181,7 +181,7 @@ Nodes in the diagram are represented by quoted strings. Nodes default to rounded bubbles but will change to a box when prefixed with "/". Note that this is the reverse of how the original SQLite generator works. The rounded bubbles are typically used for literal tokens. -Boxes are typically place holders for syntactic elements too complex to include in the current diagram. +Boxes are typically placeholders for syntactic elements too complex to include in the current diagram. Nodes starting with a non-alphanumeric character are rendered with their own font style so that punctuation tokens can be made more distinct. The following functions are available for creating diagrams: @@ -406,7 +406,7 @@ You can control the styling of the generated diagrams by passing in a style INI file with the `+-s+` option. You can use the `+--get-style+` option to generate a copy of the default -styles in the current directory so you can quickly make modifications. +styles in the current directory, so you can quickly make modifications. Here is the default styling: @@ -597,7 +597,7 @@ A regex pattern to match the node text to a style. Notes about pattern format: - If given input sequence does not match specified expression, default style will be used. shape:: -Node outline shape. Must be "bubble", "box", or "hex". +Node outline shape. Must be one of the following: "bubble", "box", or "hex". font:: Font style for the node. @@ -650,7 +650,7 @@ jsyntrax(stack( ), [ 'entity_class': 'https://www.google.com/#q=vhdl+entity+class', - '(attribute) identifier': 'http://en.wikipedia.com/wiki/VHDL' + '(attribute) identifier': 'https://en.wikipedia.com/wiki/VHDL' ]) ---- @@ -669,7 +669,7 @@ jsyntrax(stack( ), [ 'entity_class': 'https://www.google.com/#q=vhdl+entity+class', - '(attribute) identifier': 'http://en.wikipedia.com/wiki/VHDL' + '(attribute) identifier': 'https://en.wikipedia.com/wiki/VHDL' ]) .... diff --git a/jsyntrax/src/main/java/org/atpfivt/jsyntrax/generators/SVGCanvasBuilder.java b/jsyntrax/src/main/java/org/atpfivt/jsyntrax/generators/SVGCanvasBuilder.java index 55aa38c..f2612f7 100644 --- a/jsyntrax/src/main/java/org/atpfivt/jsyntrax/generators/SVGCanvasBuilder.java +++ b/jsyntrax/src/main/java/org/atpfivt/jsyntrax/generators/SVGCanvasBuilder.java @@ -284,7 +284,7 @@ public void visitLine(Line line) { this.canvas.addElement(l); pos.f = xn + endPoint.endpoint.f; } else { - // first element on line + // first element on the line pos.f = endPoint.endpoint.f; } pos.s = endPoint.endpoint.s; @@ -925,8 +925,8 @@ public static class UnitEndPoint { this.endpoint = endpoint; } - public String tag; - public Pair endpoint; + public final String tag; + public final Pair endpoint; } public UnitEndPoint getUnitEndPoint() { diff --git a/jsyntrax/src/main/java/org/atpfivt/jsyntrax/groovy_parser/Parser.groovy b/jsyntrax/src/main/java/org/atpfivt/jsyntrax/groovy_parser/Parser.groovy index bcb09bd..8bd3fb8 100644 --- a/jsyntrax/src/main/java/org/atpfivt/jsyntrax/groovy_parser/Parser.groovy +++ b/jsyntrax/src/main/java/org/atpfivt/jsyntrax/groovy_parser/Parser.groovy @@ -12,7 +12,7 @@ class Parser { private final String title Parser(String scriptText) throws CompilationFailedException { - this.scriptText = scriptText; + this.scriptText = scriptText def config = new CompilerConfiguration() config.setScriptBaseClass(SyntraxScript.class.name) def sharedData = new Binding() diff --git a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTest.java b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTest.java index 07303d8..85c3c7f 100644 --- a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTest.java +++ b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTest.java @@ -136,7 +136,7 @@ void urlMapTest() { line("/entity_class", "is", "/expression", ';') ), Map.of("entity_class", "https://www.google.com/#q=vhdl+entity+class", - "(attribute) identifier", "http://en.wikipedia.com/wiki/VHDL")); + "(attribute) identifier", "https://en.wikipedia.com/wiki/VHDL")); SVGCanvas c = canvasBuilder.generateSVG(urlMapped); String result = c.generateSVG(); Approvals.verify(result, OPTIONS); diff --git a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTitleTest.java b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTitleTest.java index 258837b..86eb16e 100644 --- a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTitleTest.java +++ b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/JSyntraxTitleTest.java @@ -15,15 +15,13 @@ import java.util.Arrays; import java.util.stream.Stream; -import static org.atpfivt.jsyntrax.groovy_parser.SyntraxScript.*; - public class JSyntraxTitleTest extends SyntraxScript { private final SVGCanvasBuilder canvasBuilder; private final StyleConfig style; public JSyntraxTitleTest() - throws IllegalAccessException, NoSuchFieldException, IOException { + throws IOException { style = new StyleConfig(1, false); JSyntraxTestUtils.updateStyle(style); canvasBuilder = new SVGCanvasBuilder().withStyle(style); diff --git a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/MainTest.java b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/MainTest.java index 2f04a7b..52cd99b 100644 --- a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/MainTest.java +++ b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/MainTest.java @@ -6,20 +6,17 @@ import java.io.*; import java.net.URISyntaxException; -import java.net.URL; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.List; import static org.junit.jupiter.api.Assertions.*; class MainTest { @Test - void testEnd2EndHappyPath() throws URISyntaxException, IOException, - NoSuchFieldException, IllegalAccessException { + void testEnd2EndHappyPath() throws URISyntaxException, IOException { Path inputPath = Paths.get(MainTest.class.getResource("jsyntrax.spec").toURI()); Path outPath = Files.createTempFile("jsyntrax-test-output", ".svg"); try { @@ -32,8 +29,7 @@ void testEnd2EndHappyPath() throws URISyntaxException, IOException, } @Test - void testWriteHelp() throws IOException, - NoSuchFieldException, IllegalAccessException { + void testWriteHelp() throws IOException { final PrintStream standardOut = System.out; final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); System.setOut(new PrintStream(outputStreamCaptor)); @@ -48,8 +44,7 @@ void testWriteHelp() throws IOException, } @Test - void printVersionTest() throws IOException, - NoSuchFieldException, IllegalAccessException { + void printVersionTest() throws IOException { final PrintStream standardOut = System.out; final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); System.setOut(new PrintStream(outputStreamCaptor)); @@ -79,7 +74,7 @@ void getStyleTest() throws IOException, URISyntaxException { @ValueSource(strings = {".png", ".PNG", ".PnG"}) @ParameterizedTest - void testPngByOutFileExtention(String ext) throws IOException, URISyntaxException, NoSuchFieldException, IllegalAccessException { + void testPngByOutFileExtention(String ext) throws IOException, URISyntaxException { Path inputPath = Paths.get(MainTest.class.getResource("jsyntrax.spec").toURI()); Path outPath = Files.createTempFile("jsyntrax-test-output", ext); try { @@ -92,7 +87,7 @@ void testPngByOutFileExtention(String ext) throws IOException, URISyntaxExceptio } @Test - void testPngByOutFileType() throws IOException, URISyntaxException, NoSuchFieldException, IllegalAccessException { + void testPngByOutFileType() throws IOException, URISyntaxException { Path inputPath = Paths.get(MainTest.class.getResource("jsyntrax.spec").toURI()); Path outPath = Paths.get(inputPath.toString().substring(0, inputPath.toString().lastIndexOf('.')) + ".png"); try { @@ -105,7 +100,7 @@ void testPngByOutFileType() throws IOException, URISyntaxException, NoSuchFieldE } @Test - void testSvgByOutFileType() throws IOException, URISyntaxException, NoSuchFieldException, IllegalAccessException { + void testSvgByOutFileType() throws IOException, URISyntaxException { Path inputPath = Paths.get(MainTest.class.getResource("jsyntrax.spec").toURI()); Path outPath = Paths.get(inputPath.toString().substring(0, inputPath.toString().lastIndexOf('.')) + ".svg"); try { @@ -118,7 +113,7 @@ void testSvgByOutFileType() throws IOException, URISyntaxException, NoSuchFieldE } @Test - void testPngByDefault() throws IOException, URISyntaxException, NoSuchFieldException, IllegalAccessException { + void testPngByDefault() throws IOException, URISyntaxException { Path inputPath = Paths.get(MainTest.class.getResource("jsyntrax.spec").toURI()); Path outPath = Paths.get(inputPath.toString().substring(0, inputPath.toString().lastIndexOf('.')) + ".png"); try { diff --git a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/PngOutputTest.java b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/PngOutputTest.java index 69b12e1..814bf51 100644 --- a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/PngOutputTest.java +++ b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/PngOutputTest.java @@ -16,7 +16,7 @@ public class PngOutputTest { @Test - public void transcodeTest() throws IllegalAccessException, NoSuchFieldException, + public void transcodeTest() throws IOException, URISyntaxException { // Given Path inputPath = Paths.get(MainTest.class.getResource("test_spec.txt").toURI()); diff --git a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/approvals/JSyntraxTest.urlMapTest.approved.svg b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/approvals/JSyntraxTest.urlMapTest.approved.svg index 9b64cd2..a02d32c 100644 --- a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/approvals/JSyntraxTest.urlMapTest.approved.svg +++ b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/approvals/JSyntraxTest.urlMapTest.approved.svg @@ -34,7 +34,7 @@ font-family:PT Sans Bold; font-size:14pt; font-weight:bold; font-style:normal; } attribute -(attribute) identifier +(attribute) identifier diff --git a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/styles/JSyntraxStyleFileTest.java b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/styles/JSyntraxStyleFileTest.java index 789b76b..5a02bcb 100644 --- a/jsyntrax/src/test/java/org/atpfivt/jsyntrax/styles/JSyntraxStyleFileTest.java +++ b/jsyntrax/src/test/java/org/atpfivt/jsyntrax/styles/JSyntraxStyleFileTest.java @@ -27,7 +27,7 @@ public class JSyntraxStyleFileTest { Files.createTempFile("jsyntrax-test-style", ".ini"); public JSyntraxStyleFileTest() - throws IOException, NoSuchFieldException, IllegalAccessException { + throws IOException { StyleConfig s = new StyleConfig(1, false); JSyntraxTestUtils.updateStyle(s); canvasBuilder = new SVGCanvasBuilder().withStyle(s); @@ -55,7 +55,7 @@ void fontFromString(){ } @Test - void configParserTest() throws IOException, NoSuchFieldException, IllegalAccessException { + void configParserTest() throws IOException { StringBuilder config = new StringBuilder(); config.append("[style]\n") .append("line_width = 50\n") @@ -86,8 +86,7 @@ void configParserTest() throws IOException, NoSuchFieldException, IllegalAccessE @Test public void svgFromConfigTest() - throws IOException, URISyntaxException, - NoSuchFieldException, IllegalAccessException { + throws IOException, URISyntaxException { // Given String config = Files.readString( Path.of(this