From 7d59a8ce69a91ac4437fb00ec5fea75f08416b89 Mon Sep 17 00:00:00 2001 From: graur Date: Tue, 23 May 2023 16:52:28 +0300 Subject: [PATCH 1/8] #2067 - added LaTex template for .tex files in LatexMojo --- .../main/java/org/eolang/maven/LatexMojo.java | 12 +-- .../eolang/maven/latex/TemplateGenerator.java | 66 +++++++++++++++ .../org/eolang/maven/latex/package-info.java | 29 +++++++ .../org/eolang/maven/latex/latex-template.txt | 7 ++ .../maven/latex/TemplateGeneratorTest.java | 82 +++++++++++++++++++ .../org/eolang/maven/latex/package-info.java | 27 ++++++ 6 files changed, 217 insertions(+), 6 deletions(-) create mode 100644 eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java create mode 100644 eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java create mode 100644 eo-maven-plugin/src/main/resources/org/eolang/maven/latex/latex-template.txt create mode 100644 eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java create mode 100644 eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java index 6e1a0d34659..d6c65d8f9f4 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java @@ -29,6 +29,7 @@ import java.nio.file.Path; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; +import org.eolang.maven.latex.TemplateGenerator; import org.eolang.maven.tojos.ForeignTojo; import org.eolang.maven.util.Home; @@ -42,10 +43,6 @@ * we need to generate summary in universe.tex file, * which will include all generated objects. And this file * should be a standalone compilable document. - * @todo #1206:30min Generate a standalone compilable document from - * each of the file in "latex" directory. All of this files are already - * ".tex" files. But they are contain only the EO code without LaTex - * structure. */ @Mojo( name = "latex", @@ -62,7 +59,7 @@ public final class LatexMojo extends SafeMojo { /** * Latex extension (.tex). */ - public static final String EXT = ".tex"; + public static final String EXT = "tex"; /** * Truncated the last part of the filename, @@ -93,8 +90,11 @@ void exec() throws IOException { final Path target = place.make( dir.resolve(LatexMojo.DIR), LatexMojo.EXT ); + final TemplateGenerator generator = new TemplateGenerator( + new XMLDocument(file).nodes("/program/listing").get(0).toString() + ); new Home(dir).save( - new XMLDocument(file).nodes("/program/listing").get(0).toString(), + generator.generate(), dir.relativize(target) ); Logger.info( diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java new file mode 100644 index 00000000000..b9ae2880fd1 --- /dev/null +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java @@ -0,0 +1,66 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.maven.latex; + +import org.cactoos.io.ResourceOf; +import org.cactoos.text.TextOf; +import org.cactoos.text.UncheckedText; + +/** + * Template generator. Generates the template from the code + * in LaTex notation as a standalone compilable document. + * + * @since 0.29 + */ +public final class TemplateGenerator { + + /** + * The code. + */ + private final String code; + + /** + * Ctor. + * @param code The code. + */ + public TemplateGenerator(final String code) { + this.code = code; + } + + /** + * Generates the template from the code from + * resources/latex-template.txt. + * @return The generated template with the code. + */ + public String generate() { + return String.format( + new UncheckedText( + new TextOf( + new ResourceOf("org/eolang/maven/latex/latex-template.txt") + ) + ).asString(), + this.code + ); + } +} diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java new file mode 100644 index 00000000000..cf8ff6710b7 --- /dev/null +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java @@ -0,0 +1,29 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/** + * LaTex. + * + * @since 0.29 + */ +package org.eolang.maven.latex; diff --git a/eo-maven-plugin/src/main/resources/org/eolang/maven/latex/latex-template.txt b/eo-maven-plugin/src/main/resources/org/eolang/maven/latex/latex-template.txt new file mode 100644 index 00000000000..29876f9a2de --- /dev/null +++ b/eo-maven-plugin/src/main/resources/org/eolang/maven/latex/latex-template.txt @@ -0,0 +1,7 @@ +\documentclass{article} +\usepackage{ffcode} +\begin{document} +\begin{ffcode} +%s +\end{ffcode} +\end{document} \ No newline at end of file diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java new file mode 100644 index 00000000000..fa64cb9b126 --- /dev/null +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java @@ -0,0 +1,82 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.maven.latex; + +import java.nio.file.Path; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +/** + * Test case for {@link org.eolang.maven.latex.TemplateGenerator}. + * + * @since 0.29 + */ +class TemplateGeneratorTest { + + /** + * Check that the template is generated. + * + * @param temp Temporary directory. + */ + @Test + void generatesTexFile(@TempDir final Path temp) { + final String code = "+package f\n\n[args] > main\n stdout \"Hello!\""; + final TemplateGenerator generator = new TemplateGenerator(code); + MatcherAssert.assertThat( + generator.generate(), + Matchers.allOf( + Matchers.containsString("\\documentclass{article}"), + Matchers.containsString("\\begin{document}"), + Matchers.containsString("\\end{document}") + ) + ); + } + + /** + * Check the full template. + * + * @param temp Temporary directory. + */ + @Test + void generatesFullTemplate(@TempDir final Path temp) { + final String code = "+package f\n[args] > main\n stdout \"Hello!\""; + final TemplateGenerator generator = new TemplateGenerator(code); + MatcherAssert.assertThat( + generator.generate(), + Matchers.stringContainsInOrder( + "\\documentclass{article}", + "\\usepackage{ffcode}", + "\\begin{document}", + "\\begin{ffcode}", + "+package f", + "[args] > main", + " stdout \"Hello!\"", + "\\end{ffcode}", + "\\end{document}" + ) + ); + } +} diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java new file mode 100644 index 00000000000..9f6ebac9d75 --- /dev/null +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java @@ -0,0 +1,27 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2016-2023 Objectionary.com + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +/** + * Test cases for {@link org.eolang.maven.optimization} package. + */ +package org.eolang.maven.latex; From eecdb57cec63d582195fbab74d2d96876e0a75ec Mon Sep 17 00:00:00 2001 From: graur Date: Tue, 23 May 2023 16:58:13 +0300 Subject: [PATCH 2/8] #2067 - added todo --- .../main/java/org/eolang/maven/latex/TemplateGenerator.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java index b9ae2880fd1..d07b8ec1269 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java @@ -32,6 +32,9 @@ * in LaTex notation as a standalone compilable document. * * @since 0.29 + * @todo #2067:30min We need to refactor TemplateGenerator class. + * And to remove redundant parts in the code, like DOM variables and + * license header. E.g.: "# The MIT License (MIT)...". */ public final class TemplateGenerator { From eb1010442a5c788c46a99fe3980bcb1109cd6b80 Mon Sep 17 00:00:00 2001 From: graur Date: Tue, 23 May 2023 17:19:43 +0300 Subject: [PATCH 3/8] #2067 - fixed todo --- .../src/main/java/org/eolang/maven/latex/TemplateGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java index d07b8ec1269..31292a95c89 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java @@ -34,7 +34,7 @@ * @since 0.29 * @todo #2067:30min We need to refactor TemplateGenerator class. * And to remove redundant parts in the code, like DOM variables and - * license header. E.g.: "# The MIT License (MIT)...". + * license header. E.g.: "<listing># The MIT License (MIT)...</listing>". */ public final class TemplateGenerator { From 2c19233370c0418cdfd84308c6d6a4b0b27581f2 Mon Sep 17 00:00:00 2001 From: graur Date: Tue, 23 May 2023 17:46:16 +0300 Subject: [PATCH 4/8] #2067 - retrigger --- .../src/main/java/org/eolang/maven/latex/TemplateGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java index 31292a95c89..8aad718822d 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java @@ -34,7 +34,7 @@ * @since 0.29 * @todo #2067:30min We need to refactor TemplateGenerator class. * And to remove redundant parts in the code, like DOM variables and - * license header. E.g.: "<listing># The MIT License (MIT)...</listing>". + * license header. E.g.: "<listing># The MIT License (MIT)...</listing>" */ public final class TemplateGenerator { From 6abd7b368093c78c22587b3cb915e90ef535c89b Mon Sep 17 00:00:00 2001 From: graur Date: Tue, 23 May 2023 17:46:29 +0300 Subject: [PATCH 5/8] #2067 - retrigger --- .../src/main/java/org/eolang/maven/latex/TemplateGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java index 8aad718822d..31292a95c89 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java @@ -34,7 +34,7 @@ * @since 0.29 * @todo #2067:30min We need to refactor TemplateGenerator class. * And to remove redundant parts in the code, like DOM variables and - * license header. E.g.: "<listing># The MIT License (MIT)...</listing>" + * license header. E.g.: "<listing># The MIT License (MIT)...</listing>". */ public final class TemplateGenerator { From db54f5092d921dd1f6f4e73a78c09c07884cd696 Mon Sep 17 00:00:00 2001 From: graur Date: Wed, 24 May 2023 13:51:58 +0300 Subject: [PATCH 6/8] #2067 - after discussion --- .../main/java/org/eolang/maven/LatexMojo.java | 9 +++-- ...plateGenerator.java => LatexTemplate.java} | 4 +-- ...eratorTest.java => LatexTemplateTest.java} | 35 ++++--------------- 3 files changed, 12 insertions(+), 36 deletions(-) rename eo-maven-plugin/src/main/java/org/eolang/maven/latex/{TemplateGenerator.java => LatexTemplate.java} (96%) rename eo-maven-plugin/src/test/java/org/eolang/maven/latex/{TemplateGeneratorTest.java => LatexTemplateTest.java} (62%) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java index d6c65d8f9f4..43b1ba1f512 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java @@ -29,7 +29,7 @@ import java.nio.file.Path; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; -import org.eolang.maven.latex.TemplateGenerator; +import org.eolang.maven.latex.LatexTemplate; import org.eolang.maven.tojos.ForeignTojo; import org.eolang.maven.util.Home; @@ -90,11 +90,10 @@ void exec() throws IOException { final Path target = place.make( dir.resolve(LatexMojo.DIR), LatexMojo.EXT ); - final TemplateGenerator generator = new TemplateGenerator( - new XMLDocument(file).nodes("/program/listing").get(0).toString() - ); new Home(dir).save( - generator.generate(), + new LatexTemplate( + new XMLDocument(file).nodes("/program/listing").get(0).toString() + ).generate(), dir.relativize(target) ); Logger.info( diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java similarity index 96% rename from eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java rename to eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java index 31292a95c89..cd260f9fcf4 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/TemplateGenerator.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java @@ -36,7 +36,7 @@ * And to remove redundant parts in the code, like DOM variables and * license header. E.g.: "<listing># The MIT License (MIT)...</listing>". */ -public final class TemplateGenerator { +public final class LatexTemplate { /** * The code. @@ -47,7 +47,7 @@ public final class TemplateGenerator { * Ctor. * @param code The code. */ - public TemplateGenerator(final String code) { + public LatexTemplate(final String code) { this.code = code; } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java similarity index 62% rename from eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java rename to eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java index fa64cb9b126..5c5164e0eef 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/TemplateGeneratorTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java @@ -23,49 +23,26 @@ */ package org.eolang.maven.latex; -import java.nio.file.Path; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; /** - * Test case for {@link org.eolang.maven.latex.TemplateGenerator}. + * Test case for {@link LatexTemplate}. * * @since 0.29 */ -class TemplateGeneratorTest { - - /** - * Check that the template is generated. - * - * @param temp Temporary directory. - */ - @Test - void generatesTexFile(@TempDir final Path temp) { - final String code = "+package f\n\n[args] > main\n stdout \"Hello!\""; - final TemplateGenerator generator = new TemplateGenerator(code); - MatcherAssert.assertThat( - generator.generate(), - Matchers.allOf( - Matchers.containsString("\\documentclass{article}"), - Matchers.containsString("\\begin{document}"), - Matchers.containsString("\\end{document}") - ) - ); - } +class LatexTemplateTest { /** * Check the full template. - * - * @param temp Temporary directory. */ @Test - void generatesFullTemplate(@TempDir final Path temp) { - final String code = "+package f\n[args] > main\n stdout \"Hello!\""; - final TemplateGenerator generator = new TemplateGenerator(code); + void generatesFullTemplate() { MatcherAssert.assertThat( - generator.generate(), + new LatexTemplate( + "+package f\n[args] > main\n stdout \"Hello!\"" + ).generate(), Matchers.stringContainsInOrder( "\\documentclass{article}", "\\usepackage{ffcode}", From 6569e17a5aabb0b269d60893f47782215412e0d0 Mon Sep 17 00:00:00 2001 From: graur Date: Wed, 24 May 2023 15:50:29 +0300 Subject: [PATCH 7/8] #2067 - renamed method to asString() --- .../src/main/java/org/eolang/maven/LatexMojo.java | 2 +- .../main/java/org/eolang/maven/latex/LatexTemplate.java | 8 ++++---- .../java/org/eolang/maven/latex/LatexTemplateTest.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java b/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java index 43b1ba1f512..7d38579e499 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/LatexMojo.java @@ -93,7 +93,7 @@ void exec() throws IOException { new Home(dir).save( new LatexTemplate( new XMLDocument(file).nodes("/program/listing").get(0).toString() - ).generate(), + ).asString(), dir.relativize(target) ); Logger.info( diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java index cd260f9fcf4..d879179458c 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java @@ -28,11 +28,11 @@ import org.cactoos.text.UncheckedText; /** - * Template generator. Generates the template from the code + * Latex template. Generates the LaTex template from the code * in LaTex notation as a standalone compilable document. * * @since 0.29 - * @todo #2067:30min We need to refactor TemplateGenerator class. + * @todo #2067:30min We need to refactor LatexTemplate class. * And to remove redundant parts in the code, like DOM variables and * license header. E.g.: "<listing># The MIT License (MIT)...</listing>". */ @@ -54,9 +54,9 @@ public LatexTemplate(final String code) { /** * Generates the template from the code from * resources/latex-template.txt. - * @return The generated template with the code. + * @return The generated template with the code as string. */ - public String generate() { + public String asString() { return String.format( new UncheckedText( new TextOf( diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java index 5c5164e0eef..129bd1d9d0b 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java @@ -42,7 +42,7 @@ void generatesFullTemplate() { MatcherAssert.assertThat( new LatexTemplate( "+package f\n[args] > main\n stdout \"Hello!\"" - ).generate(), + ).asString(), Matchers.stringContainsInOrder( "\\documentclass{article}", "\\usepackage{ffcode}", From a6cd56e6fe5f5719b3c08b27a08e75f2c8669201 Mon Sep 17 00:00:00 2001 From: graur Date: Thu, 25 May 2023 10:59:51 +0300 Subject: [PATCH 8/8] #2067 - updated since meta --- .../src/main/java/org/eolang/maven/latex/LatexTemplate.java | 2 +- .../src/main/java/org/eolang/maven/latex/package-info.java | 2 +- .../test/java/org/eolang/maven/latex/LatexTemplateTest.java | 2 +- .../src/test/java/org/eolang/maven/latex/package-info.java | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java index d879179458c..65d092ce074 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/LatexTemplate.java @@ -31,7 +31,7 @@ * Latex template. Generates the LaTex template from the code * in LaTex notation as a standalone compilable document. * - * @since 0.29 + * @since 0.30 * @todo #2067:30min We need to refactor LatexTemplate class. * And to remove redundant parts in the code, like DOM variables and * license header. E.g.: "<listing># The MIT License (MIT)...</listing>". diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java index cf8ff6710b7..c47b5c95d0b 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/latex/package-info.java @@ -24,6 +24,6 @@ /** * LaTex. * - * @since 0.29 + * @since 0.30 */ package org.eolang.maven.latex; diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java index 129bd1d9d0b..9d99512d228 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/LatexTemplateTest.java @@ -30,7 +30,7 @@ /** * Test case for {@link LatexTemplate}. * - * @since 0.29 + * @since 0.30 */ class LatexTemplateTest { diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java index 9f6ebac9d75..daefe7822b8 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/latex/package-info.java @@ -22,6 +22,8 @@ * SOFTWARE. */ /** - * Test cases for {@link org.eolang.maven.optimization} package. + * Test cases for {@link org.eolang.maven.latex} package. + * + * @since 0.30 */ package org.eolang.maven.latex;