From 91f31116f1000f7764a9a06769aff24f6e5dad0e Mon Sep 17 00:00:00 2001 From: Max Rydahl Andersen Date: Mon, 8 Jan 2024 09:53:00 +0100 Subject: [PATCH] Add exclude + additionals option to AssembleDownstreamDocumentation Why: * downstreamdoc.yaml is used to generate the list of docs used by downstream doc builds and today its hardcoded thus very limited for downstream docs ability to adjust without changing the quarkus repo. This change addreses the need by: * adding a DOWNSTREAM_CONFIG_FILE to *optionally* override the hardcoded downstreamdoc.yaml * adding a DOWNSTREAM_ADDITONALS env var to the downstream doc build that can be used to add docs to the list of docs used by downstream doc builds * adding a DOWNSTREAM_EXCLUDES env var to the downstream doc build that can be used to exclude docs from the list of docs used by downstream doc builds + additionals (cherry picked from commit 865a88214a5aae7148c2cf63b5e78b637babda82) --- .../AssembleDownstreamDocumentation.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/docs/src/main/java/io/quarkus/docs/generation/AssembleDownstreamDocumentation.java b/docs/src/main/java/io/quarkus/docs/generation/AssembleDownstreamDocumentation.java index dbb4c74cd9b5c..0acc2d32ddf43 100755 --- a/docs/src/main/java/io/quarkus/docs/generation/AssembleDownstreamDocumentation.java +++ b/docs/src/main/java/io/quarkus/docs/generation/AssembleDownstreamDocumentation.java @@ -1,11 +1,17 @@ package io.quarkus.docs.generation; +//These are here to allow running the script directly from command line/IDE +//The real deps and call are in the pom.xml +//DEPS org.jboss.logging:jboss-logging:3.4.1.Final +//DEPS com.fasterxml.jackson.core:jackson-databind:2.12.3 +//DEPS com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.8.0.rc1 import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Map; @@ -88,7 +94,30 @@ public static void main(String[] args) throws Exception { ObjectMapper yamlObjectMapper = new ObjectMapper(new YAMLFactory()); yamlObjectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); - ConfigFile configFile = yamlObjectMapper.readValue(new File("downstreamdoc.yaml"), ConfigFile.class); + String configFilePath = System.getenv("DOWNSTREAM_CONFIG_FILE"); + if (configFilePath == null) { + configFilePath = "downstreamdoc.yaml"; + } + ConfigFile configFile = yamlObjectMapper.readValue(new File(configFilePath), ConfigFile.class); + + String additionals = System.getenv("DOWNSTREAM_ADDITIONALS"); + if (additionals != null) { + String[] additional_files = additionals.split(","); + LOG.info("Additional files: " + Arrays.toString(additional_files)); + for (String file : additional_files) { + configFile.guides.add(file); + } + } + + String excludes = System.getenv("DOWNSTREAM_EXCLUDES"); + if (excludes != null) { + String[] excludePatterns = excludes.split(","); + LOG.info("Excluding patterns: " + Arrays.toString(excludePatterns)); + for (String pattern : excludePatterns) { + Pattern regexPattern = Pattern.compile(pattern); + configFile.guides.removeIf(guide -> regexPattern.matcher(guide).find()); + } + } Set guides = new TreeSet<>(); Set simpleIncludes = new TreeSet<>();