in scripts/sync-docs.js [334:385]
function extractDocsVersionTasks(project, version) {
const projectPath = `${tempPath}/${project.name}`;
const isIngressController = project.name === 'apisix-ingress-controller';
return new Listr([
{
title: `Checkout ${project.name} version: ${version}`,
task: () => gitMap[project.name]
.cwd(projectPath)
.checkout(
isIngressController
? `remotes/origin/v${version}`
: `remotes/origin/release/${version}`,
['-f'],
),
},
{
title: 'Generate API docs for APISIX',
enabled: () => project.name === 'apisix'
&& os.platform() === 'linux'
&& isFileExisted(`./${tempPath}/${project.name}/autodocs`),
task: () => generateAPIDocs(project),
},
{
title: `Copy to target path`,
task: async () => {
const branchName = isIngressController ? `v${version}` : `release/${version}`;
const projectName = project.name;
const docsPath = `${projectPath}/docs`;
const enSrcDocs = `${docsPath}/en/latest`;
const zhSrcDocs = `${docsPath}/zh/latest`;
const displayVersionName = (projectName === 'apisix' && versionMap?.[version]) || version;
const enTargetDocs = `${websitePath}/docs-${projectName}_versioned_docs/version-${displayVersionName}`;
const zhTargetDocs = `${websitePath}/i18n/zh/docusaurus-plugin-content-docs-docs-${projectName}/version-${displayVersionName}`;
await Promise.allSettled([
copyDocs(enSrcDocs, enTargetDocs)
.then(() => replaceMDElements(projectName, [enTargetDocs], branchName))
.then(() => handleConfig2Sidebar(
enTargetDocs,
enTargetDocs,
displayVersionName,
`${websitePath}/docs-${project.name}_versioned_sidebars`,
)),
copyDocs(zhSrcDocs, zhTargetDocs).then(() => replaceMDElements(projectName, [zhTargetDocs], branchName)),
]).catch(() => {
/* ignore */
});
},
},
]);
}