Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small adjustments for documentation related content #37003

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading