You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by ju...@apache.org on 2022/03/06 12:32:54 UTC
[apisix-website] branch master updated: feat: support auto generate PDK (#931)
This is an automated email from the ASF dual-hosted git repository.
juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git
The following commit(s) were added to refs/heads/master by this push:
new 9564571 feat: support auto generate PDK (#931)
9564571 is described below
commit 95645718222f2c91da2910624115f8e84ce47cdd
Author: Zeping Bai <bz...@apache.org>
AuthorDate: Sun Mar 6 20:32:49 2022 +0800
feat: support auto generate PDK (#931)
---
scripts/sync-docs.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 54 insertions(+), 7 deletions(-)
diff --git a/scripts/sync-docs.js b/scripts/sync-docs.js
index dec9374..81f3bb2 100644
--- a/scripts/sync-docs.js
+++ b/scripts/sync-docs.js
@@ -2,6 +2,7 @@ const childProcess = require("child_process");
const fs = require("fs");
const path = require("path");
const process = require("process");
+const os = require('os');
const listr = require("listr");
const simpleGit = require("simple-git");
const semver = require('semver');
@@ -68,7 +69,7 @@ const tasks = new listr([
return {
title: `Extract ${project.name} ${version} documents`,
task: () => {
- const steps = [
+ return new listr([
{
title: `Checkout ${project.name} version: ${version}`,
task: async () => {
@@ -84,6 +85,15 @@ const tasks = new listr([
}
},
{
+ title: "Generate API docs for APISIX",
+ enabled: () => {
+ return os.platform() === "linux" && project.name === 'apisix' && isFileExisted(`./${tempPath}/${project.name}/autodocs`);
+ },
+ task: () => {
+ return generateAPIDocs(project);
+ }
+ },
+ {
title: "Add English documents",
task: () => {
childProcess.execSync(
@@ -95,7 +105,7 @@ const tasks = new listr([
{
title: "Add Chinese documents",
task: () => {
- if (isFileExisted(`./tmp/${project.name}/docs/zh/latest`) !== false) {
+ if (isFileExisted(`./${tempPath}/${project.name}/docs/zh/latest`) !== false) {
copyFolder(
project.latestDocs.zh,
`${websitePath}/i18n/zh/docusaurus-plugin-content-docs-docs-${project.name}/version-${version}`
@@ -103,8 +113,7 @@ const tasks = new listr([
}
}
}
- ];
- return new listr(steps)
+ ]);
}
}
});
@@ -126,9 +135,11 @@ const tasks = new listr([
const steps = [
{
title: `Checkout ${project.name} next version`,
- task: async () => {
- await git.cwd(`${tempPath}/${project.name}/`).checkout(`remotes/origin/${project.branch}`, ['-f']);
- }
+ task: () => new Promise(async (resolve) => {
+ git.cwd(`${tempPath}/${project.name}/`).checkout(`remotes/origin/${project.branch}`, ['-f']).then(() => {
+ resolve();
+ });
+ })
},
{
title: "Replace elements inside MD files",
@@ -136,6 +147,15 @@ const tasks = new listr([
replaceMDElements(project.name, [`${tempPath}/${project.name}/docs`], project.branch);
copyAllDocs(project);
}
+ },
+ {
+ title: "Generate API docs for APISIX",
+ enabled: () => {
+ return os.platform() === "linux" && project.name === 'apisix' && isFileExisted(`./${tempPath}/${project.name}/autodocs`);
+ },
+ task: () => {
+ return generateAPIDocs(project);
+ }
}
];
return new listr(steps);
@@ -296,3 +316,30 @@ const copyAllDocs = (project) => {
"zh"
);
};
+
+/**
+ * Generate APISIX API Docs
+ * @return {Listr<Listr.ListrContext>}
+ * @param project
+ * @param version
+ */
+const generateAPIDocs = (project) => {
+ return new listr([
+ {
+ title: "Generate markdown files",
+ task: () => {
+ childProcess.spawnSync(`autodocs/generate.sh`, ['build'], {
+ cwd: `./${tempPath}/${project.name}`
+ });
+ }
+ },
+ {
+ title: "Copy API docs",
+ task: () => {
+ if (isFileExisted(`./${tempPath}/${project.name}/autodocs/output`) !== false) {
+ copyFolder(`${tempPath}/${project.name}/autodocs/output`, `${project.latestDocs.en}/pdk-docs`);
+ }
+ }
+ }
+ ]);
+}