Skip to content

Commit

Permalink
Add exclude + additionals option to AssembleDownstreamDocumentation
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maxandersen committed Jan 8, 2024
1 parent 0ee923c commit ec276d4
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Path> guides = new TreeSet<>();
Set<Path> simpleIncludes = new TreeSet<>();
Set<Path> includes = new TreeSet<>();
Expand Down

0 comments on commit ec276d4

Please sign in to comment.