Skip to content

Commit 3ac8a1d

Browse files
Allow skipping API docs in local previews (Qiskit#1750)
The preview app is slow due because the it searches through the docs folder each time we load a page. Eric had the idea to improve the speed by removing API docs from the image. Since the API docs are so large, this roughly halves the time taken per page load. Writers can ask to include API docs using the `--apis` option. Helps with Qiskit#1720. --------- Co-authored-by: Eric Arellano <14852634+Eric-Arellano@users.noreply.github.com>
1 parent 85a33c8 commit 3ac8a1d

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

.github/workflows/weekly-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
run: npm ci
3131
- name: Start local Docker preview
3232
run: |
33-
./start &
33+
./start --apis &
3434
sleep 20
3535
- name: Check all pages render
3636
run: >

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ You can preview the docs locally by following these two steps:
8080

8181
The preview application does not include the top nav bar. Instead, navigate to the folder you want with the links in the home page. You can return to the home page at any time by clicking "IBM Quantum Documentation Preview" in the top-left of the header.
8282

83-
Warning: `./start` does not check if there is a new version of the docs application available. You can run `docker pull qiskit/documentation` to update to the latest version of the app.
83+
Warning: `./start` does not check if there is a new version of the docs application available. You can run `docker pull qiskit/documentation` to update to the latest version of the app. It will also ignore the API docs to speed things up, if you want to view them, run `./start --apis`.
8484

8585
### API docs authors: How to preview your changes
8686

start

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,12 @@ from typing import Iterator
1919
PWD = Path(__file__).parent
2020

2121

22-
def translation_volume_mounts() -> Iterator[str]:
23-
"""Return the CLI args to mount each language in the translations/ folder.
24-
25-
Unlike the root `Dockerfile`, we cannot use `-v $PWD/translations:/home/node/app/docs` because
26-
Docker complains that the volume is already mounted when we mount the `/docs` folder. So, instead
27-
we need to be more specific to mount each language's folder.
28-
"""
29-
for path in PWD.glob("translations/*"):
30-
if not path.is_dir():
31-
continue
32-
yield from ["-v", f"{path}:/home/node/app/docs/{path.name}"]
33-
22+
def skip_apis() -> tuple[str]:
23+
"""Mounts an empty directory to /docs/api/ to effectively exclude it"""
24+
if "--apis" in sys.argv:
25+
return ()
26+
print("Skipping API docs for speed; use --apis to include them")
27+
return ("-v", "/home/node/app/docs/api")
3428

3529
def main() -> None:
3630
print(
@@ -44,7 +38,7 @@ def main() -> None:
4438
"run",
4539
"-v",
4640
f"{PWD}/docs:/home/node/app/docs",
47-
*translation_volume_mounts(),
41+
*skip_apis(),
4842
"-v",
4943
f"{PWD}/public:/home/node/app/packages/preview/public",
5044
"-p",

0 commit comments

Comments
 (0)