From 6dd189e3a6c66e23e78e8acfd1123bcc531a032b Mon Sep 17 00:00:00 2001 From: RahulGautamSingh Date: Wed, 29 May 2024 11:09:07 +0545 Subject: [PATCH] docs: automate docs for `releaseTimestamp` and `sourceUrl` support (#29225) Co-authored-by: Rhys Arkins Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com> --- lib/modules/datasource/nuget/index.ts | 12 ++++------- tools/docs/datasources.ts | 30 ++++++++++++++++++--------- tools/docs/utils.ts | 4 ++-- tools/docs/versioning.ts | 4 ++-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/modules/datasource/nuget/index.ts b/lib/modules/datasource/nuget/index.ts index 1307901f72ef36..66c3b7b1346f30 100644 --- a/lib/modules/datasource/nuget/index.ts +++ b/lib/modules/datasource/nuget/index.ts @@ -19,15 +19,11 @@ export class NugetDatasource extends Datasource { override readonly registryStrategy = 'merge'; override readonly releaseTimestampSupport = true; - override readonly releaseTimestampNote = ` - For the v2 API, the release timestamp is determined from the \`Publised\` tag and, - for the v3 API, the release timestamp is determined from the \`published\` field in the results. - `; + override readonly releaseTimestampNote = + 'For the v2 API, the release timestamp is determined from the `Published` tag. And, for the v3 API, the release timestamp is determined from the `published` field in the results.'; override readonly sourceUrlSupport = 'package'; - override readonly sourceUrlNote = ` - For the v2 API, the source URL is determined from the \`ProjectUrl\` tag and, - for the v3 API, the source URL is determined from the \`metadata.repository@url\` field in the results. - `; + override readonly sourceUrlNote = + 'For the v2 API, the source URL is determined from the `ProjectUrl` tag. And, for the v3 API, the source URL is determined from the `metadata.repository@url` field in the results.'; readonly v2Api = new NugetV2Api(); diff --git a/tools/docs/datasources.ts b/tools/docs/datasources.ts index db7bcd1f0e568c..7615cd3052ae0c 100644 --- a/tools/docs/datasources.ts +++ b/tools/docs/datasources.ts @@ -24,6 +24,10 @@ export async function generateDatasources( defaultConfig, customRegistrySupport, defaultVersioning, + releaseTimestampSupport, + releaseTimestampNote, + sourceUrlSupport, + sourceUrlNote, } = definition; const displayName = getDisplayName(datasource, definition); datasourceContent += `* ${getModuleLink( @@ -39,24 +43,30 @@ export async function generateDatasources( # ${displayName} Datasource `; md += '\n\n'; - md += `**Identifier**: \`${id}\`\n\n`; + + let tableContent = '## Table of values\n\n'; + + tableContent += '| Name | Vaue | Notes |\n'; + tableContent += '| :-- | :-- | :-- |\n'; + + tableContent += `| Identifier | \`${id}\` | \n`; if (defaultVersioning) { - md += `**Default versioning**: \`${defaultVersioning}\`\n\n`; + tableContent += `| Default versioning | \`${defaultVersioning}\` | \n`; } else { - md += `**Default versioning**: no default versioning\n\n`; + tableContent += `| Default versioning | No default versioning | \n`; } + + tableContent += `| Custom registry support | ${customRegistrySupport ? 'Yes' : 'No'} | \n`; + tableContent += `| Release timestamp support | ${releaseTimestampSupport ? 'Yes' : 'No'} | ${releaseTimestampNote ?? ''} |\n`; + tableContent += `| Source URL support | ${sourceUrlSupport === 'none' ? 'No' : 'Yes'} | ${sourceUrlNote ?? ''} |\n`; + + md += tableContent + '\n'; md += formatUrls(urls); - md += `**Custom registry support**: \n\n`; - if (customRegistrySupport) { - md += `✅ Custom registries are supported.\n\n`; - } else { - md += `❌ No custom registry support.\n\n`; - } md += await formatDescription('datasource', datasource); if (defaultConfig) { md += - '**Default configuration**:\n\n```json\n' + + '## Default configuration\n\n```json\n' + JSON.stringify(defaultConfig, undefined, 2) + '\n```\n'; } diff --git a/tools/docs/utils.ts b/tools/docs/utils.ts index ab780472c1f984..8e4f7f81f20d17 100644 --- a/tools/docs/utils.ts +++ b/tools/docs/utils.ts @@ -50,7 +50,7 @@ export function replaceContent(content: string, txt: string): string { export function formatUrls(urls: string[] | null | undefined): string { if (Array.isArray(urls) && urls.length) { - return `**References**:\n\n${urls + return `## References\n\n${urls .map((url) => ` - [${url}](${url})`) .join('\n')}\n\n`; } @@ -65,7 +65,7 @@ export async function formatDescription( if (!content) { return ''; } - return `**Description**:\n\n${content}\n`; + return `## Description\n\n${content}\n`; } export function getModuleLink(module: string, title?: string): string { diff --git a/tools/docs/versioning.ts b/tools/docs/versioning.ts index eb379f357b0e39..6982ed612faa65 100644 --- a/tools/docs/versioning.ts +++ b/tools/docs/versioning.ts @@ -45,9 +45,9 @@ export async function generateVersioning( # ${displayName} Versioning `; md += '\n\n'; - md += `**Identifier**: \`${id}\`\n\n`; + md += `## Identifier\n\n \`${id}\` \n\n`; md += formatUrls(urls); - md += `**Ranges/Constraints:**\n\n`; + md += `## Ranges/Constraints\n\n`; if (supportsRanges) { md += `✅ Ranges are supported.\n\nValid \`rangeStrategy\` values are: ${( supportedRangeStrategies ?? []