mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-26 23:39:13 +00:00
a300036a1c
* refactor(platform): programatically mark Platforms as experimental As part of future changes, we'll want to be able to more straightforwardly determine whether a given Platform is experimental. To do this, we can add a new optional `experimental` flag to the `Platform`. As part of having this available, we can refactor how our docs for Platforms are built, and replace a hand-authored experimental notice, we can automagically insert it into the built docs. To make sure that we don't break the rendering of the Markdown for Mkdocs, we need to insert the experimental notice after the page heading. As we're now using the Platform itself, not only the ID, we need to refactor how `tools/docs/platforms.ts` renders the pages. * docs(platforms): clarify which Platforms are experimental (#41249) * chore: format code block --------- Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import { codeBlock } from 'common-tags';
|
|
import platforms from '../../lib/modules/platform/api.ts';
|
|
import { readFile, updateFile } from '../utils/index.ts';
|
|
import type { OpenItems } from './github-query-items.ts';
|
|
import { generateFeatureAndBugMarkdown } from './github-query-items.ts';
|
|
import { getModuleLink, replaceContent } from './utils.ts';
|
|
|
|
export async function generatePlatforms(
|
|
dist: string,
|
|
platformIssuesMap: OpenItems,
|
|
): Promise<void> {
|
|
for (const [id, platform] of platforms) {
|
|
let md = codeBlock`
|
|
---
|
|
edit_url: https://github.com/renovatebot/renovate/edit/main/lib/modules/platform/${id}/readme.md
|
|
---
|
|
`;
|
|
md += '\n\n';
|
|
|
|
const contents = await readFile(`lib/modules/platform/${id}/readme.md`);
|
|
const lines = contents.split('\n');
|
|
|
|
if (platform.experimental) {
|
|
// make sure that we don't mangle the <h1> of the page, as it is used to infer the page title by Mkdocs
|
|
md += lines[0]; // title of the platform
|
|
md += '\n\n';
|
|
|
|
md += codeBlock`
|
|
<!-- prettier-ignore -->
|
|
!!! warning "This feature is flagged as experimental"
|
|
Experimental features might be changed or even removed at any time.
|
|
`;
|
|
md += '\n\n';
|
|
|
|
md += lines.slice(1).join('\n');
|
|
}
|
|
|
|
md += contents;
|
|
md += generateFeatureAndBugMarkdown(platformIssuesMap, id);
|
|
|
|
await updateFile(`${dist}/modules/platform/${id}/index.md`, md);
|
|
}
|
|
|
|
let platformContent = 'Supported values for `platform` are: \n\n';
|
|
for (const [id, platform] of platforms) {
|
|
if (platform.experimental) {
|
|
continue;
|
|
}
|
|
|
|
platformContent += `* ${getModuleLink(id, `\`${id}\``)}\n`;
|
|
}
|
|
|
|
platformContent +=
|
|
'\nAdditionally, the following `platform` values are experimental:\n\n';
|
|
|
|
for (const [id, platform] of platforms) {
|
|
if (!platform.experimental) {
|
|
continue;
|
|
}
|
|
|
|
platformContent += `* ${getModuleLink(id, `\`${id}\``)}\n`;
|
|
}
|
|
|
|
let indexContent = await readFile(`docs/usage/modules/platform/index.md`);
|
|
indexContent = replaceContent(indexContent, platformContent);
|
|
await updateFile(`${dist}/modules/platform/index.md`, indexContent);
|
|
}
|