Skip to content

Commit

Permalink
Merge pull request #37003 from gsmet/related-content-adjustments
Browse files Browse the repository at this point in the history
Small adjustments for documentation related content
  • Loading branch information
gsmet committed Nov 10, 2023
2 parents 1b2471c + a448c5a commit c28838a
Showing 1 changed file with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -462,8 +462,8 @@ public Map<String, DocMetadata> metadataByFile() {
.collect(Collectors.toMap(v -> v.filename, v -> v, (o1, o2) -> o1, TreeMap::new));
}

public Map<String, DocRelations> relationsByFile(Map<String, DocMetadata> metadataByFile) {
Map<String, DocRelations> relationsByFile = new TreeMap<>();
public Map<String, DocRelations> relationsByUrl(Map<String, DocMetadata> metadataByFile) {
Map<String, DocRelations> relationsByUrl = new TreeMap<>();

for (Entry<String, DocMetadata> currentMetadataEntry : metadataByFile.entrySet()) {
DocRelations docRelations = new DocRelations();
Expand All @@ -482,7 +482,8 @@ public Map<String, DocRelations> relationsByFile(Map<String, DocMetadata> 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;
Expand All @@ -494,16 +495,17 @@ public Map<String, DocRelations> relationsByFile(Map<String, DocMetadata> 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
Expand Down Expand Up @@ -649,9 +651,9 @@ public int compareTo(DocMetadata that) {
@JsonInclude(value = Include.NON_EMPTY)
public static class DocRelations {

Set<DocRelation> sameTopics = new TreeSet<>(DocRelationComparator.INSTANCE);
final Set<DocRelation> sameTopics = new TreeSet<>(DocRelationComparator.INSTANCE);

Set<DocRelation> sameExtensions = new TreeSet<>(DocRelationComparator.INSTANCE);
final Set<DocRelation> sameExtensions = new TreeSet<>(DocRelationComparator.INSTANCE);

public Set<DocRelation> getSameTopics() {
return sameTopics;
Expand All @@ -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;
}

Expand All @@ -690,6 +695,10 @@ public String getUrl() {
return url;
}

public String getType() {
return type;
}

public int getMatches() {
return matches;
}
Expand Down

0 comments on commit c28838a

Please sign in to comment.