Skip to content

Commit

Permalink
Update information (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
Netyyyy authored Dec 27, 2024
1 parent 8da1aed commit ecab55c
Showing 1 changed file with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,40 @@ private int getMaxLength(Stream<String> stringStream) {
return stringStream.map(String::trim).mapToInt(String::length).max().orElse(0);
}

/**
* To reduce variance, use the same description width as the current document.
*/
private int getDescriptionColumnWidth(String outputFile, Stream<String> stringStream) {
Map<String, Integer> DES_WIDTH = new HashMap<>();
DES_WIDTH.put("configuration-properties-azure-active-directory.md", 641);
DES_WIDTH.put("configuration-properties-azure-active-directory-b2c.md", 470);
DES_WIDTH.put("configuration-properties-azure-service-bus.md", 194);
DES_WIDTH.put("configuration-properties-azure-service-bus-jms.md", 446);
return DES_WIDTH.getOrDefault(outputFile.substring(outputFile.lastIndexOf("/") + 1),
getMaxLength(stringStream));
}

private String getServiceName(String outputFile) {
HashMap<String, String> DES_WIDTH = new HashMap<>();
DES_WIDTH.put("configuration-properties-all.md", "Spring Cloud Azure");
DES_WIDTH.put("configuration-properties-azure-active-directory.md", "Microsoft Entra");
DES_WIDTH.put("configuration-properties-azure-active-directory-b2c.md", "Azure Active Directory B2C");
DES_WIDTH.put("configuration-properties-azure-app-configuration.md", "Azure App Configuration");
DES_WIDTH.put("configuration-properties-azure-cosmos-db.md", "Azure Cosmos DB");
DES_WIDTH.put("configuration-properties-azure-event-hubs.md", "Azure Event Hubs");
DES_WIDTH.put("configuration-properties-azure-key-vault.md", "Azure Key Vault");
DES_WIDTH.put("configuration-properties-azure-key-vault-certificates.md", "Azure Key Vault Certificates");
DES_WIDTH.put("configuration-properties-azure-key-vault-secrets.md", "Azure Key Vault Secrets");
DES_WIDTH.put("configuration-properties-azure-service-bus.md", "Azure Service Bus");
DES_WIDTH.put("configuration-properties-azure-service-bus-jms.md", "Azure Service Bus JMS");
DES_WIDTH.put("configuration-properties-azure-storage.md", "Azure Storage");
DES_WIDTH.put("configuration-properties-azure-storage-blob.md", "Azure Storage Blob");
DES_WIDTH.put("configuration-properties-azure-storage-file-share.md", "Azure Storage File Share");
DES_WIDTH.put("configuration-properties-azure-storage-queue.md", "Azure Storage Queue");
DES_WIDTH.put("configuration-properties-global.md", "Spring Cloud Azure Global");
return DES_WIDTH.getOrDefault(outputFile.substring(outputFile.lastIndexOf("/") + 1), null);
}

/**
* Generate properties markdown files.
* @param outputFile the output file
Expand All @@ -289,21 +323,31 @@ private int getMaxLength(Stream<String> stringStream) {
*/
private void generatePropertiesFile(String outputFile, TreeMap<String, String> descriptions, String date) {
int nameColumnWidth = getMaxLength(descriptions.keySet().stream());
int descriptionColumnWidth = getMaxLength(descriptions.values().stream());
int descriptionColumnWidth = getDescriptionColumnWidth(outputFile, descriptions.values().stream());
Path path = Paths.get(outputFile);
String serviceName = getServiceName(outputFile);
try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
writer.write("---");
writer.newLine();
writer.write(String.format("title: %s configuration properties", serviceName));
writer.newLine();
writer.write(String.format("description: This reference doc contains all %s configuration properties.",
serviceName));
writer.newLine();
writer.write("author: KarlErickson");
writer.newLine();
writer.write("ms.author: v-yonghuiye");
writer.write("ms.author: hangwan");
writer.newLine();
writer.write("ms.date: " + date);
writer.newLine();
writer.write("ms.topic: reference");
writer.newLine();
writer.write("ms.custom: devx-track-java, spring-cloud-azure, devx-track-extended-java");
writer.newLine();
writer.write("---");
writer.newLine();
writer.newLine();
writer.write("## " + generateTitleName(outputFile) + " properties");
writer.write(String.format("# %s configuration properties", serviceName));
writer.newLine();
writer.newLine();
writer.write("> [!div class=\"mx-tdBreakAll\"]");
Expand Down

0 comments on commit ecab55c

Please sign in to comment.