Skip to content

Commit 3202214

Browse files
authored
Rewrite documentation building to use Docusaurus (#149)
1 parent e19245d commit 3202214

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+29017
-6754
lines changed

.flake8

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[flake8]
22
filename =
3-
./docs/*.py,
43
./scripts/*.py,
54
./src/*.py,
65
./tests/*.py
76
per-file-ignores =
8-
docs/*: D
97
scripts/*: D
108
tests/*: D
119

.github/workflows/check_docs.yaml renamed to .github/workflows/check_async_docstrings.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Check documentation status
1+
name: Check async docstrings
22

33
on:
44
workflow_call:
55

66
jobs:
7-
check_docs:
8-
name: Check whether documentation is up-to-date
7+
check_async_docstrings:
8+
name: Check whether doctrings for async methods are up-to-date
99
runs-on: ubuntu-latest
1010

1111
steps:
@@ -22,6 +22,3 @@ jobs:
2222

2323
- name: Check async docstrings
2424
run: make check-async-docstrings
25-
26-
- name: Check docs building
27-
run: make check-docs

.github/workflows/docs.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build and deploy docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
build_and_deploy_docs:
11+
environment:
12+
name: github-pages
13+
permissions:
14+
contents: write
15+
pages: write
16+
id-token: write
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: 18
29+
cache: npm
30+
cache-dependency-path: website/package-lock.json
31+
32+
- name: Install Node.js dependencies
33+
run: |
34+
npm install
35+
npm update @apify/docs-theme
36+
working-directory: ./website
37+
38+
# We do this as early as possible to prevent conflicts if someone else would push something in the meantime
39+
- name: Commit the updated package.json and lockfile
40+
run: |
41+
git config user.name 'GitHub Actions'
42+
git config user.email 'github-actions[bot]@users.noreply.github.com'
43+
git add website/package.json
44+
git add website/package-lock.json
45+
git diff-index --quiet HEAD || git commit -m 'chore: Automatic docs theme update [skip ci]' || true
46+
git push
47+
48+
- name: Set up Python
49+
uses: actions/setup-python@v4
50+
with:
51+
python-version: 3.8
52+
53+
- name: Install Python dependencies
54+
run: make install-dev
55+
56+
- name: Build generated API reference
57+
run: make build-api-reference
58+
59+
- name: Build Docusaurus docs
60+
run: npm run build
61+
working-directory: ./website
62+
63+
- name: Set up GitHub Pages
64+
uses: actions/configure-pages@v3
65+
66+
- name: Upload GitHub Pages artifact
67+
uses: actions/upload-pages-artifact@v2
68+
with:
69+
path: ./website/build
70+
71+
- name: Deploy artifact to GitHub Pages
72+
uses: actions/deploy-pages@v2
73+
74+
- name: Invalidate CloudFront cache
75+
run: gh workflow run invalidate.yaml --repo apify/apify-docs-private
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}

.github/workflows/release.yaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,38 @@ on:
2424
- final
2525

2626
jobs:
27+
should_release:
28+
name: Check whether to release
29+
if: (!startsWith(github.event.head_commit.message, 'docs:') || github.event_name == 'workflow_dispatch')
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Dummy step
33+
run: true
34+
2735
lint_and_type_checks:
2836
name: Run lint and type_checks
37+
needs: [should_release]
2938
uses: ./.github/workflows/lint_and_type_checks.yaml
3039

3140
unit_tests:
3241
name: Run unit tests
42+
needs: [should_release]
3343
uses: ./.github/workflows/unit_tests.yaml
3444

45+
check_async_docstrings:
46+
name: Check whether async dostrings are up to date
47+
needs: [should_release]
48+
uses: ./.github/workflows/check_async_docstrings.yaml
49+
3550
integration_tests:
3651
name: Run integration tests
52+
needs: [should_release]
3753
uses: ./.github/workflows/integration_tests.yaml
3854
secrets: inherit
3955

40-
check_docs:
41-
name: Check whether the documentation is up to date
42-
uses: ./.github/workflows/check_docs.yaml
43-
4456
publish_to_pypi:
4557
name: Publish to PyPI
46-
needs: [lint_and_type_checks, unit_tests, integration_tests, check_docs]
58+
needs: [should_release, lint_and_type_checks, unit_tests, check_async_docstrings, integration_tests]
4759
runs-on: ubuntu-latest
4860
permissions:
4961
contents: write

.github/workflows/run_checks.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
needs: [lint_and_type_checks]
1414
uses: ./.github/workflows/unit_tests.yaml
1515

16-
check_docs:
17-
name: Check whether the documentation is up to date
18-
uses: ./.github/workflows/check_docs.yaml
16+
check_async_docstrings:
17+
name: Check async dostrings
18+
uses: ./.github/workflows/check_async_docstrings.yaml
1919

2020
integration_tests:
2121
name: Run integration tests
22-
needs: [lint_and_type_checks, unit_tests, check_docs]
22+
needs: [lint_and_type_checks, unit_tests, check_async_docstrings]
2323
uses: ./.github/workflows/integration_tests.yaml
2424
secrets: inherit

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ build/
1515
.vscode
1616
.idea
1717
.DS_Store
18+
19+
docs/changelog.md

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ line_length = 150
44
use_parentheses = True
55
multi_line_output = 3
66
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
7-
known_first_party = apify_client, apify_shared
7+
known_first_party = apify,apify_client,apify_shared

.markdownlint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
default: true
2+
line-length:
3+
line_length: 150
4+
ul-style: dash
5+
no-inline-html: false

.pre-commit-config.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ repos:
2525
language: system
2626
pass_filenames: false
2727

28-
- id: check-docs
29-
name: Check whether docs are up-to-date
30-
entry: make check-docs
31-
language: system
32-
pass_filenames: false
33-
3428
- id: check-changelog
3529
name: Check whether current version is mentioned in changelog
3630
entry: make check-changelog-entry

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ We use `autopep8` and `isort` to automatically format the code to a common forma
3030

3131
We use `flake8` for linting, `mypy` for type checking and `pytest` for unit testing. To run these tools, just run `make check-code`.
3232

33+
## Integration tests
34+
35+
We have integration tests which send API requests using the API client to the Apify Platform.
36+
To run these tests, you need to set the `APIFY_TEST_USER_API_TOKEN` environment variable to the API token of the Apify user you want to use for the tests,
37+
and then start them with `make integration-tests`.
38+
39+
If you want to run the integration tests on a different environment than the main Apify Platform,
40+
you need to set the `APIFY_INTEGRATION_TESTS_API_URL` environment variable to the right URL to the Apify API you want to use.
41+
3342
## Documentation
3443

3544
We use the [Google docstring format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for documenting the code.

0 commit comments

Comments
 (0)