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

docs: automate docs for releaseTimestamp and sourceUrl support #29225

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 4 additions & 8 deletions lib/modules/datasource/nuget/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
30 changes: 20 additions & 10 deletions tools/docs/datasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export async function generateDatasources(
defaultConfig,
customRegistrySupport,
defaultVersioning,
releaseTimestampSupport,
releaseTimestampNote,
sourceUrlSupport,
sourceUrlNote,
} = definition;
const displayName = getDisplayName(datasource, definition);
datasourceContent += `* ${getModuleLink(
Expand All @@ -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`;
RahulGautamSingh marked this conversation as resolved.
Show resolved Hide resolved
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';
}
Expand Down
4 changes: 2 additions & 2 deletions tools/docs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
}
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tools/docs/versioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? []
Expand Down