Skip to content

Commit 8ef23d7

Browse files
author
Teo Koon Peng
committed
fix docs pathing
Signed-off-by: Teo Koon Peng <koonpeng@openrobotics.org>
1 parent 0d4201d commit 8ef23d7

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

.github/workflows/ghpages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Extract docs
5353
run: |
5454
. /rmf_demos_ws/install/setup.bash
55-
pipenv run python3 scripts/extract_docs.py -o docs
55+
pnpm run generate-docs
5656
- name: Upload artifact
5757
uses: actions/upload-pages-artifact@v1
5858
with:

packages/api-server/api_server/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ async def custom_swagger_ui_html():
222222
openapi_url=openapi_url,
223223
title=app.title + " - Swagger UI",
224224
oauth2_redirect_url=app.swagger_ui_oauth2_redirect_url,
225-
swagger_js_url="/static/swagger-ui-bundle.js",
226-
swagger_css_url="/static/swagger-ui.css",
225+
swagger_js_url=f"{app_config.public_url.geturl()}/static/swagger-ui-bundle.js",
226+
swagger_css_url=f"{app_config.public_url.geturl()}/static/swagger-ui.css",
227227
)
228228

229229

@@ -238,7 +238,7 @@ async def redoc_html():
238238
return get_redoc_html(
239239
openapi_url=openapi_url,
240240
title=app.title + " - ReDoc",
241-
redoc_js_url="/static/redoc.standalone.js",
241+
redoc_js_url=f"{app_config.public_url.geturl()}/static/redoc.standalone.js",
242242
)
243243

244244

packages/api-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"test:cov": "../../scripts/pipenv run python -m coverage run scripts/test.py",
1313
"test:report": "../../scripts/pipenv run python -m coverage html && xdg-open htmlcov/index.html",
1414
"lint": "../../scripts/pipenv run pyright && ../../scripts/pipenv run pylint api_server --ignore=ros_pydantic,rmf_api",
15-
"generate-models": "./generate-models.sh"
15+
"generate-models": "./generate-models.sh",
16+
"generate-docs": "RMF_API_SERVER_CONFIG=scripts/docs_config.py ../../scripts/pipenv run python scripts/extract_docs.py -o docs"
1617
},
1718
"devDependencies": {
1819
"pipenv-install": "workspace:*"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import os
2+
3+
from api_server.default_config import config
4+
5+
here = os.path.dirname(__file__)
6+
7+
config.update(
8+
{
9+
"public_url": "/rmf-web",
10+
}
11+
)

packages/api-server/scripts/extract_docs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,22 @@ def cleanup():
2525

2626
atexit.register(cleanup)
2727
server_proc = subprocess.Popen(
28-
("pnpm", "start"), cwd=f"{os.path.dirname(__file__)}/..", start_new_session=True
28+
("python", "-m", "api_server"),
29+
cwd=f"{os.path.dirname(__file__)}/..",
30+
start_new_session=True,
2931
)
3032

3133
time.sleep(5) # wait for server to be ready
3234
outdir = f"{args.output}"
3335
os.makedirs(outdir, exist_ok=True)
3436

35-
with urlopen("http://localhost:8000/docs") as resp:
37+
base_url = "http://localhost:8000/rmf-web"
38+
with urlopen(f"{base_url}/docs") as resp:
3639
html: bytes = resp.read()
3740
with open(f"{outdir}/index.html", "bw") as f:
3841
f.write(html)
3942

40-
with urlopen("http://localhost:8000/openapi.json") as resp:
43+
with urlopen(f"{base_url}/openapi.json") as resp:
4144
openapi = json.loads(resp.read())
4245
openapi["servers"] = [
4346
{
@@ -54,7 +57,7 @@ def cleanup():
5457
]
5558

5659
for p in files_to_download:
57-
with urlopen(f"http://localhost:8000{p}") as resp:
60+
with urlopen(f"{base_url}{p}") as resp:
5861
fp = f"{outdir}{p}"
5962
os.makedirs(os.path.dirname(fp), exist_ok=True)
6063
with open(fp, "bw") as f:

0 commit comments

Comments
 (0)