From ec276d4193602124ece47cf7b6c4adf1eabf3432 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 for two things: * to generate the list of docs used by downstream doc builds * used to match in github notifications to determine if a PR is a downstream relevant doc PR This change addreses the need by: * 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 --- .../AssembleDownstreamDocumentation.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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..5924ccd39ff24 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,18 @@ 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; @@ -90,6 +97,25 @@ public static void main(String[] args) throws Exception { ConfigFile configFile = yamlObjectMapper.readValue(new File("downstreamdoc.yaml"), 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<>(); Set includes = new TreeSet<>();