From a448c5a5e44d1a394e61af04b0efb8e52cab2861 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Fri, 10 Nov 2023 14:53:36 +0100 Subject: [PATCH] Small adjustments for documentation related content --- .../generation/YamlMetadataGenerator.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/docs/src/main/java/io/quarkus/docs/generation/YamlMetadataGenerator.java b/docs/src/main/java/io/quarkus/docs/generation/YamlMetadataGenerator.java index 79048b6c42731..f999e542440c4 100644 --- a/docs/src/main/java/io/quarkus/docs/generation/YamlMetadataGenerator.java +++ b/docs/src/main/java/io/quarkus/docs/generation/YamlMetadataGenerator.java @@ -125,7 +125,7 @@ public void writeYamlFiles() throws StreamWriteException, DatabindException, IOE om.writeValue(targetDir.resolve("indexByType.yaml").toFile(), index); om.writeValue(targetDir.resolve("indexByFile.yaml").toFile(), metadata); - om.writeValue(targetDir.resolve("relations.yaml").toFile(), index.relationsByFile(metadata)); + om.writeValue(targetDir.resolve("relations.yaml").toFile(), index.relationsByUrl(metadata)); om.writeValue(targetDir.resolve("errorsByType.yaml").toFile(), messages); om.writeValue(targetDir.resolve("errorsByFile.yaml").toFile(), messages.allByFile()); @@ -462,8 +462,8 @@ public Map metadataByFile() { .collect(Collectors.toMap(v -> v.filename, v -> v, (o1, o2) -> o1, TreeMap::new)); } - public Map relationsByFile(Map metadataByFile) { - Map relationsByFile = new TreeMap<>(); + public Map relationsByUrl(Map metadataByFile) { + Map relationsByUrl = new TreeMap<>(); for (Entry currentMetadataEntry : metadataByFile.entrySet()) { DocRelations docRelations = new DocRelations(); @@ -482,7 +482,8 @@ public Map relationsByFile(Map metada } if (extensionMatches > 0) { docRelations.sameExtensions.add( - new DocRelation(candidateMetadata.getTitle(), candidateMetadata.getUrl(), extensionMatches)); + new DocRelation(candidateMetadata.getTitle(), candidateMetadata.getUrl(), + candidateMetadata.getType(), extensionMatches)); } int topicMatches = 0; @@ -494,16 +495,17 @@ public Map relationsByFile(Map metada if (topicMatches > 0 && (!candidateMetadata.getTopics().contains(COMPATIBILITY_TOPIC) || currentMetadataEntry.getValue().getTopics().contains(COMPATIBILITY_TOPIC))) { docRelations.sameTopics - .add(new DocRelation(candidateMetadata.getTitle(), candidateMetadata.getUrl(), topicMatches)); + .add(new DocRelation(candidateMetadata.getTitle(), candidateMetadata.getUrl(), + candidateMetadata.getType(), topicMatches)); } } if (!docRelations.isEmpty()) { - relationsByFile.put(currentMetadataEntry.getKey(), docRelations); + relationsByUrl.put(currentMetadataEntry.getValue().getUrl(), docRelations); } } - return relationsByFile; + return relationsByUrl; } // convenience @@ -649,9 +651,9 @@ public int compareTo(DocMetadata that) { @JsonInclude(value = Include.NON_EMPTY) public static class DocRelations { - Set sameTopics = new TreeSet<>(DocRelationComparator.INSTANCE); + final Set sameTopics = new TreeSet<>(DocRelationComparator.INSTANCE); - Set sameExtensions = new TreeSet<>(DocRelationComparator.INSTANCE); + final Set sameExtensions = new TreeSet<>(DocRelationComparator.INSTANCE); public Set getSameTopics() { return sameTopics; @@ -670,15 +672,18 @@ public boolean isEmpty() { @JsonInclude(value = Include.NON_EMPTY) public static class DocRelation { - String title; + final String title; + + final String url; - String url; + final String type; - int matches; + final int matches; - DocRelation(String title, String url, int matches) { + DocRelation(String title, String url, String type, int matches) { this.title = title; this.url = url; + this.type = type; this.matches = matches; } @@ -690,6 +695,10 @@ public String getUrl() { return url; } + public String getType() { + return type; + } + public int getMatches() { return matches; }