Skip to content

Commit 9d8ad94

Browse files
committed
docs: add versioned documentation (next, 1.6, 0.6)
Set up Docusaurus doc versioning with three versions: - next (unreleased, from /docs directory) - 1.6 (current release) - 0.6 (last version of previous major) Includes version dropdown in navbar, versioned API reference, and automated version snapshotting in the release workflow. Remove hardcoded version links (1.3, 2.2) pointing to sdk.apify.com and the duplicate version dropdown logic, keeping only the one from docusaurus.config.js.
1 parent 02a18ea commit 9d8ad94

File tree

431 files changed

+359348
-28
lines changed

Some content is hidden

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

431 files changed

+359348
-28
lines changed

.github/workflows/manual_release_stable.yaml

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,83 @@ jobs:
104104
# TODO: add job for publish package to Conda
105105
# https://github.com/apify/crawlee-python/issues/104
106106

107+
version_docs:
108+
name: Version docs
109+
needs: [release_prepare, changelog_update, pypi_publish]
110+
runs-on: ubuntu-latest
111+
outputs:
112+
version_docs_commitish: ${{ steps.commit_versioned_docs.outputs.commit_long_sha }}
113+
permissions:
114+
contents: write
115+
env:
116+
NODE_VERSION: 22
117+
PYTHON_VERSION: 3.14
118+
119+
steps:
120+
- name: Checkout repository
121+
uses: actions/checkout@v6
122+
with:
123+
token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
124+
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
125+
126+
- name: Set up Node
127+
uses: actions/setup-node@v6
128+
with:
129+
node-version: ${{ env.NODE_VERSION }}
130+
131+
- name: Set up Python
132+
uses: actions/setup-python@v6
133+
with:
134+
python-version: ${{ env.PYTHON_VERSION }}
135+
136+
- name: Set up uv package manager
137+
uses: astral-sh/setup-uv@v7
138+
with:
139+
python-version: ${{ env.PYTHON_VERSION }}
140+
141+
- name: Install Python dependencies
142+
run: uv run poe install-dev
143+
144+
- name: Install website dependencies
145+
run: |
146+
cd website
147+
corepack enable
148+
yarn install
149+
150+
- name: Snapshot the current version
151+
run: |
152+
cd website
153+
VERSION="$(python -c "import tomllib, pathlib; print(tomllib.loads(pathlib.Path('../pyproject.toml').read_text())['project']['version'])")"
154+
MAJOR_MINOR="$(echo "$VERSION" | cut -d. -f1-2)"
155+
export MAJOR_MINOR
156+
# Remove existing version if present (patch releases override)
157+
rm -rf "versioned_docs/version-${MAJOR_MINOR}"
158+
rm -rf "versioned_sidebars/version-${MAJOR_MINOR}-sidebars.json"
159+
jq 'map(select(. != env.MAJOR_MINOR))' versions.json > tmp.json && mv tmp.json versions.json
160+
# Copy changelog
161+
cp ../CHANGELOG.md ../docs/changelog.md
162+
# Build API reference and create version snapshots
163+
bash build_api_reference.sh
164+
npx docusaurus docs:version "$MAJOR_MINOR"
165+
npx docusaurus api:version "$MAJOR_MINOR"
166+
167+
- name: Commit and push versioned docs
168+
id: commit_versioned_docs
169+
uses: EndBug/add-and-commit@v10
170+
with:
171+
add: "website/versioned_docs website/versioned_sidebars website/versions.json"
172+
message: "docs: version ${{ needs.release_prepare.outputs.version_number }} docs [skip ci]"
173+
default_author: github_actions
174+
107175
doc_release:
108176
name: Doc release
109-
needs: [changelog_update, pypi_publish]
177+
needs: [changelog_update, pypi_publish, version_docs]
110178
permissions:
111179
contents: write
112180
pages: write
113181
id-token: write
114182
uses: ./.github/workflows/_release_docs.yaml
115183
with:
116-
# Use the ref from the changelog update to include the updated changelog.
117-
ref: ${{ needs.changelog_update.outputs.changelog_commitish }}
184+
# Use the version_docs commit to include both changelog and versioned docs.
185+
ref: ${{ needs.version_docs.outputs.version_docs_commitish }}
118186
secrets: inherit

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ packages = ["src/crawlee"]
140140
[tool.ruff]
141141
line-length = 120
142142
include = ["src/**/*.py", "tests/**/*.py", "docs/**/*.py", "website/**/*.py"]
143+
exclude = [
144+
"website/versioned_docs/**",
145+
]
143146
extend-exclude = ["src/crawlee/project_template"]
144147

145148
[tool.ruff.lint]
@@ -251,6 +254,7 @@ include = ["src", "tests", "scripts", "docs", "website"]
251254
exclude = [
252255
"src/crawlee/project_template",
253256
"docs/guides/code_examples/storage_clients/custom_storage_client_example.py",
257+
"website/versioned_docs",
254258
]
255259

256260
[[tool.ty.overrides]]

website/docusaurus.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ module.exports = {
9494
path: '../docs',
9595
sidebarPath: './sidebars.js',
9696
rehypePlugins: [externalLinkProcessor],
97-
// disableVersioning: true,
9897
editUrl: (doc) => {
9998
return `https://github.com/apify/crawlee-python/edit/master/website/${doc.versionDocsDirPath}/${doc.docPath}`;
10099
},
@@ -118,6 +117,7 @@ module.exports = {
118117
},
119118
sortSidebar: groupSort,
120119
routeBasePath: 'api',
120+
python: true,
121121
pythonOptions: {
122122
pythonModulePath: path.join(__dirname, '../src/crawlee'),
123123
moduleShortcutsPath: path.join(__dirname, 'module_shortcuts.json'),
@@ -172,6 +172,12 @@ module.exports = {
172172
includeVersionedDocs: false,
173173
enableLlmsFullTxt: true,
174174
relativePaths: false,
175+
excludeRoutes: [
176+
'/python/api/[0-9]*/**',
177+
'/python/api/[0-9]*',
178+
'/python/api/next/**',
179+
'/python/api/next',
180+
],
175181
},
176182
},
177183
],
@@ -281,6 +287,12 @@ module.exports = {
281287
label: 'Blog',
282288
position: 'left',
283289
},
290+
{
291+
type: 'docsVersionDropdown',
292+
position: 'right',
293+
dropdownItemsBefore: [],
294+
dropdownItemsAfter: [],
295+
},
284296
],
285297
},
286298
colorMode: {

website/src/theme/Navbar/Content/index.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Link from '@docusaurus/Link';
2-
import { useLocation } from '@docusaurus/router';
32
import { useThemeConfig } from '@docusaurus/theme-common';
43
import {
54
splitNavbarItems,
@@ -38,32 +37,10 @@ function NavbarContentLayout({ left, right }) {
3837
);
3938
}
4039

41-
const VERSIONS_ITEM = {
42-
type: 'docsVersionDropdown',
43-
position: 'left',
44-
label: 'Versions',
45-
dropdownItemsAfter: [
46-
{
47-
href: 'https://sdk.apify.com/docs/guides/getting-started',
48-
label: '2.2',
49-
},
50-
{
51-
href: 'https://sdk.apify.com/docs/1.3.1/guides/getting-started',
52-
label: '1.3',
53-
},
54-
],
55-
dropdownItemsBefore: [],
56-
};
57-
5840
export default function NavbarContent() {
59-
const location = useLocation();
6041
const mobileSidebar = useNavbarMobileSidebar();
6142
const items = useNavbarItems();
62-
const effectiveItems = location.pathname?.endsWith('/python/')
63-
|| location.pathname?.endsWith('/python')
64-
? items
65-
: [...items, VERSIONS_ITEM];
66-
const [leftItems, rightItems] = splitNavbarItems(effectiveItems);
43+
const [leftItems, rightItems] = splitNavbarItems(items);
6744
const searchBarItem = items.find((item) => item.type === 'search');
6845
return (
6946
<NavbarContentLayout
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"entryPoints":{"index":{"label":"Index","path":"src/index.ts"}},"packageRoot":".","packagePath":".","packageSlug":".","packageName":"crawlee"}]

0 commit comments

Comments
 (0)