Skip to content

Commit 57d47dd

Browse files
authored
Merge pull request #1391 from hkad98/jkd/docs-prerender-api-ref
perf(docs): pre-render API reference HTML in Python
2 parents 7d482a0 + dd6fc46 commit 57d47dd

21 files changed

+1024
-79
lines changed

.github/workflows/netlify-deploy-v2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
uses: actions/cache@v4
4545
with:
4646
path: docs/versioned_docs/${{ matrix.version.section }}
47-
key: version-docs-${{ matrix.version.section }}-${{ steps.sha.outputs.sha }}
47+
key: version-docs-${{ hashFiles('scripts/docs/*.py', 'scripts/docs/templates/**', 'docs/*_template.md') }}-${{ matrix.version.section }}-${{ steps.sha.outputs.sha }}
4848
- name: Checkout
4949
if: steps.cache.outputs.cache-hit != 'true'
5050
uses: actions/checkout@v4
@@ -54,7 +54,7 @@ jobs:
5454
- name: Checkout branch packages
5555
if: steps.cache.outputs.cache-hit != 'true'
5656
run: |
57-
git checkout origin/${{ matrix.version.branch }} -- gooddata-api-client/ packages/gooddata-sdk/ packages/gooddata-pandas/ scripts/script-requirements.txt
57+
git checkout origin/${{ matrix.version.branch }} -- gooddata-api-client/ packages/gooddata-sdk/ packages/gooddata-pandas/
5858
- name: Setup Python
5959
if: steps.cache.outputs.cache-hit != 'true'
6060
uses: actions/setup-python@v5

.github/workflows/rw-collect-changes.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
python-modules:
4141
- '.docker/**'
4242
- 'packages/**'
43+
- 'scripts/docs/**'
4344
- '*.mk'
4445
- 'Makefile'
4546
- Dockerfile

.github/workflows/rw-python-tests.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ jobs:
4444
- name: pep8 and formatting check
4545
run: |
4646
make format
47+
docs-scripts-tests:
48+
runs-on: ubuntu-latest
49+
if: ${{inputs.changed-python-modules == 'true'}}
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
- name: Set up python 3.14
54+
uses: astral-sh/setup-uv@v6
55+
with:
56+
python-version: 3.14
57+
- name: Install dependencies
58+
run: |
59+
uv sync --group test --locked
60+
- name: Test docs scripts
61+
run: |
62+
make test-docs-scripts
4763
types-check:
4864
runs-on: ubuntu-latest
4965
if: ${{inputs.changed-python-modules == 'true'}}

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ remove-cassettes:
108108
for project in $(NO_CLIENT_GD_PROJECTS_DIRS); do $(MAKE) -C packages/$${project} $@ || RESULT=$$?; done; \
109109
exit $$RESULT
110110

111+
.PHONY: test-docs-scripts
112+
test-docs-scripts:
113+
uv run pytest scripts/docs/tests/ -v
114+
111115
.PHONY: new-docs
112116
new-docs:
113117
cd docs; \

docs/Dockerfile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ RUN apt-get update && apt-get install -y git make curl
77
# Copy only dependency manifests and package source before installing.
88
COPY scripts/script-requirements.txt /scripts/script-requirements.txt
99
COPY gooddata-api-client /gooddata-api-client
10-
COPY packages/gooddata-sdk /gooddata-sdk
11-
COPY packages/gooddata-pandas /gooddata-pandas
10+
COPY packages/gooddata-sdk /packages/gooddata-sdk
11+
COPY packages/gooddata-pandas /packages/gooddata-pandas
1212

1313
RUN --mount=type=cache,target=/root/.cache/pip \
1414
pip install -r /scripts/script-requirements.txt
@@ -21,9 +21,7 @@ WORKDIR /docs
2121

2222
RUN python json_builder.py && \
2323
python python_ref_builder.py api_spec.toml data.json latest content/en && \
24-
mkdir versioned_docs/latest && \
25-
mv -f data.json ./versioned_docs/latest/data.json && \
26-
mv -f content/en/latest/links.json ./versioned_docs/latest/links.json
24+
rm -f data.json
2725

2826
FROM node:20.18.0-bookworm-slim
2927

@@ -37,9 +35,9 @@ COPY --from=builder /docs /docs
3735

3836
WORKDIR /docs
3937

40-
# Use BuildKit cache mounts so npm/Go package downloads survive layer rebuilds
38+
# npm cache mount speeds up rebuilds; Go modules are stored in the image
39+
# layer so Hugo can resolve them at runtime.
4140
RUN --mount=type=cache,target=/root/.npm \
42-
--mount=type=cache,target=/root/go/pkg/mod \
4341
npm install && \
4442
hugo mod get
4543

docs/class_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ linkTitle: "LINK"
33
no_list: true
44
---
55

6-
{{< api-ref-class "PATH" >}}
6+
CONTENT

docs/content/en/latest/api-reference/_index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ linkTitle: "API Reference"
44
weight: 99
55
navigationLabel: true
66
---
7-
8-
9-
Placeholder for gerenerated API reference.

docs/content/en/latest/pandas/_index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,3 @@ linkTitle: "GOODDATA PANDAS"
44
weight: 59
55
navigationLabel: true
66
---
7-
8-
9-
Placeholder for gerenerated API reference - pandas.

docs/function_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ superheading: "PARENT."
55
weight: 100
66
---
77

8-
{{< api-ref "PATH" >}}
8+
CONTENT

docs/module_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ linkTitle: "LINK"
44
no_list: true
55
---
66

7-
{{< api-ref-module "PATH" >}}
7+
CONTENT

0 commit comments

Comments
 (0)