Skip to content
Snippets Groups Projects
Unverified Commit 6dd189e3 authored by RahulGautamSingh's avatar RahulGautamSingh Committed by GitHub
Browse files

docs: automate docs for `releaseTimestamp` and `sourceUrl` support (#29225)

parent 3162e6ea
Branches
Tags
No related merge requests found
......@@ -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();
......
......@@ -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';
}
......
......@@ -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 {
......
......@@ -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 ?? []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment