Skip to content

Commit

Permalink
[doc] enable to include env name
Browse files Browse the repository at this point in the history
  • Loading branch information
rmannibucau committed Oct 3, 2023
1 parent caa9073 commit 2e27aff
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static java.util.Collections.enumeration;
Expand All @@ -49,6 +50,9 @@ public DocumentationGenerator(final Path sourceBase, final Map<String, String> c
@Override
@SuppressWarnings("unchecked")
public void run() {
final boolean includeEnv = Boolean.parseBoolean(configuration.get("includeEnvironmentNames"));
final var envPattern = includeEnv ? Pattern.compile("[^A-Za-z0-9]") : null;

try (final var json = new JsonMapperImpl(List.of(), c -> Optional.empty())) {
final var docs = findUrls();
while (docs.hasMoreElements()) {
Expand Down Expand Up @@ -78,6 +82,7 @@ public void run() {
.map(it -> {
final var name = it.get("name").toString();
return "* `" + name + "`" +
(includeEnv ? " (`" + envPattern.matcher(name).replaceAll("_") + "`)" : "") +
(Boolean.TRUE.equals(it.get("required")) ? "*" : "") +
ofNullable(it.get("defaultValue"))
.map(v -> " (default: `" + v + "`)")
Expand Down

0 comments on commit 2e27aff

Please sign in to comment.