You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ti...@apache.org on 2022/12/14 09:34:10 UTC

[pulsar-site] branch main updated: Accept version parameter when generating swagger files (#331)

This is an automated email from the ASF dual-hosted git repository.

tison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git


The following commit(s) were added to refs/heads/main by this push:
     new 911d0e55c09 Accept version parameter when generating swagger files (#331)
911d0e55c09 is described below

commit 911d0e55c0939d67febef7b827b1d11ceb2be016
Author: tison <wa...@gmail.com>
AuthorDate: Wed Dec 14 17:34:04 2022 +0800

    Accept version parameter when generating swagger files (#331)
    
    Signed-off-by: tison <wa...@gmail.com>
---
 site2/website-next/contribute/release-process.md | 2 +-
 tools/pytools/README.md                          | 7 +++++--
 tools/pytools/bin/rest-apidoc-generator.py       | 3 ++-
 tools/pytools/lib/execute/swagger_generator.py   | 4 ++--
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/site2/website-next/contribute/release-process.md b/site2/website-next/contribute/release-process.md
index df214eb5241..ff227ed6ec2 100644
--- a/site2/website-next/contribute/release-process.md
+++ b/site2/website-next/contribute/release-process.md
@@ -448,7 +448,7 @@ cd pulsar-site
 git checkout -b fix/swagger-file
 cd tools/pytools
 poetry install
-poetry run bin/rest-apidoc-generator.py --master-path=/path/to/pulsar
+poetry run bin/rest-apidoc-generator.py --master-path=/path/to/pulsar --version 2.10.2
 ```
 
 Send out a PR request for review.
diff --git a/tools/pytools/README.md b/tools/pytools/README.md
index e2a50779de6..fa7bfd7eefd 100644
--- a/tools/pytools/README.md
+++ b/tools/pytools/README.md
@@ -115,7 +115,10 @@ poetry run bin/reference-doc-generator.py --master-path=<path> [--version=<VERSI
 This executable generates REST API docs based on Swagger:
 
 ```bash
-poetry run bin/rest-apidoc-generator.py [--master-path=<path>]
+poetry run bin/rest-apidoc-generator.py [--master-path=<path>] [--version=<VERSION>]
 ```
 
-... where `master-path` is path to the main repo. If it's empty, the script will clone the main repo on the fly.
+... where:
+
+1. `master-path` is path to the main repo. If it's empty, the script will clone the main repo on the fly.
+2. `version` is the version of the main repo, default to `master` a.k.a. the latest master branch;
diff --git a/tools/pytools/bin/rest-apidoc-generator.py b/tools/pytools/bin/rest-apidoc-generator.py
index 73aeb104f0b..ac26f5f2a02 100755
--- a/tools/pytools/bin/rest-apidoc-generator.py
+++ b/tools/pytools/bin/rest-apidoc-generator.py
@@ -28,6 +28,7 @@ from execute import swagger_generator, swagger_sorter
 if __name__ == '__main__':
     parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
     parser.add_argument('--master-path', type=str, metavar='PATH', help='path to pulsar main repo')
+    parser.add_argument('--version', default='master', metavar='VERSION', help='version of Apache Pulsar')
 
     args = parser.parse_args()
 
@@ -39,6 +40,6 @@ if __name__ == '__main__':
         else:
             master = Path(args.master_path)
 
-        swagger_generator.execute(master)
+        swagger_generator.execute(master, args.version)
         swagger_sorter.execute(site_path() / 'static' / 'swagger')
 
diff --git a/tools/pytools/lib/execute/swagger_generator.py b/tools/pytools/lib/execute/swagger_generator.py
index 7e95fe6bb7b..109c497b204 100644
--- a/tools/pytools/lib/execute/swagger_generator.py
+++ b/tools/pytools/lib/execute/swagger_generator.py
@@ -22,11 +22,11 @@ from command import find_command, run
 from constant import site_path
 
 
-def execute(master: Path):
+def execute(master: Path, version: str):
     master_swaggers = master / 'pulsar-broker' / 'target' / 'docs'
 
     if not master_swaggers.exists():  # generate master swaggers
         mvn = find_command('mvn', msg="mvn is required")
         run(mvn, '-pl', 'pulsar-broker', 'install', '-DskipTests', '-Pswagger', cwd=master)
 
-    shutil.copytree(master_swaggers, site_path() / 'static' / 'swagger' / 'master', dirs_exist_ok=True)
+    shutil.copytree(master_swaggers, site_path() / 'static' / 'swagger' / version, dirs_exist_ok=True)