From a1a9664303540ca0ea86fc2e4d423c90fec9e9d4 Mon Sep 17 00:00:00 2001 From: Tobias Haindl Date: Sun, 14 Jul 2024 20:39:59 +0200 Subject: [PATCH] GH-644: implement review suggestions --- .../modulith/docs/Documenter.java | 23 +++++++++++++++++++ .../modulith/docs/DocumenterTest.java | 8 +++---- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java b/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java index b91f6a5e6..e4b9dd0dc 100644 --- a/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java +++ b/spring-modulith-docs/src/main/java/org/springframework/modulith/docs/Documenter.java @@ -1199,14 +1199,37 @@ private Options(@Nullable String outputFolder, boolean clean) { this.clean = clean; } + /** + * Creates a default {@link Options} instance configuring a default output folder based on the detected build tool (see {@link Options#DEFAULT_LOCATION}). + * Use {@link #withOutputFolder(String)} if you want to customize the output folder. + * Per default the output folder is wiped before any files are written to it. + * Use {@link #withoutClean()} to disable cleaning of the output folder. + * + * @return will never be {@literal null}. + * @see #withoutClean() + * @see #withOutputFolder(String) + */ public static Options defaults() { return new Options(DEFAULT_LOCATION, true); } + /** + * Disables the cleaning of the output folder before any file is written. + * + * @return will never be {@literal null}. + */ public Options withoutClean() { return new Options(outputFolder, false); } + /** + * Configures the output folder for the created files. + * The given directory is wiped before any files are written to it. + * + * @param folder if null the default location based on the detected build tool will be used (see {@link Options#DEFAULT_LOCATION}). + * The given folder will be created if it does not exist already. Existing folders are supported as well. + * @return will never be {@literal null}. + */ public Options withOutputFolder(String folder) { return new Options(folder, clean); } diff --git a/spring-modulith-integration-test/src/test/java/org/springframework/modulith/docs/DocumenterTest.java b/spring-modulith-integration-test/src/test/java/org/springframework/modulith/docs/DocumenterTest.java index a47f4a58b..aebbe8c01 100644 --- a/spring-modulith-integration-test/src/test/java/org/springframework/modulith/docs/DocumenterTest.java +++ b/spring-modulith-integration-test/src/test/java/org/springframework/modulith/docs/DocumenterTest.java @@ -83,8 +83,8 @@ void customizesOutputLocation(@TempDir Path outputDirectory) throws IOException @Test void shouldCleanOutputLocation(@TempDir Path outputDirectory) throws IOException { - Path filePath = createTestFile(outputDirectory); - Path nestedFiledPath = createTestFileInSubdirectory(outputDirectory); + var filePath = createTestFile(outputDirectory); + var nestedFiledPath = createTestFileInSubdirectory(outputDirectory); new Documenter(ApplicationModules.of(Application.class), outputDirectory.toString()).writeDocumentation(); @@ -95,8 +95,8 @@ void shouldCleanOutputLocation(@TempDir Path outputDirectory) throws IOException @Test void shouldNotCleanOutputLocation(@TempDir Path outputDirectory) throws IOException { - Path filePath = createTestFile(outputDirectory); - Path nestedFiledPath = createTestFileInSubdirectory(outputDirectory); + var filePath = createTestFile(outputDirectory); + var nestedFiledPath = createTestFileInSubdirectory(outputDirectory); new Documenter(ApplicationModules.of(Application.class), Options.defaults().withOutputFolder(outputDirectory.toString()).withoutClean()) .writeDocumentation();