Skip to content

Commit a8b8b5f

Browse files
Viicossvenevs
andauthored
Fix source locations in documentation for external packages (pydantic#11710)
Co-authored-by: Stephen McDowell <[email protected]>
1 parent f14b7da commit a8b8b5f

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

.github/workflows/ci.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,14 @@ jobs:
5656

5757
- run: uv run python -c 'import docs.plugins.main'
5858

59-
# Adding local symlinks gets nice source locations like
60-
# pydantic_core/core_schema.py
61-
# instead of
62-
# .venv/lib/python3.10/site-packages/pydantic_core/core_schema.py
59+
# Taken from docs-build.sh
6360
- name: prepare shortcuts for extra modules
6461
run: |
6562
ln -s .venv/lib/python*/site-packages/pydantic_core pydantic_core
6663
ln -s .venv/lib/python*/site-packages/pydantic_settings pydantic_settings
6764
ln -s .venv/lib/python*/site-packages/pydantic_extra_types pydantic_extra_types
6865
69-
- run: uv run mkdocs build
66+
- run: PYTHONPATH="$PWD${PYTHONPATH:+:${PYTHONPATH}}" uv run mkdocs build
7067

7168
test-memray:
7269
name: Test memray

.github/workflows/docs-update.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,7 @@ jobs:
7777

7878
- run: uv run python -c 'import docs.plugins.main'
7979

80-
# Adding local symlinks gets nice source locations like
81-
# pydantic_core/core_schema.py
82-
# instead of
83-
# .venv/lib/python3.10/site-packages/pydantic_core/core_schema.py
80+
# Taken from docs-build.sh
8481
- name: Prepare shortcuts for extra modules
8582
run: |
8683
ln -s .venv/lib/python*/site-packages/pydantic_core pydantic_core
@@ -92,7 +89,7 @@ jobs:
9289
git config --global user.name "${{ github.actor }}"
9390
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
9491
95-
- run: uv run mike deploy -b docs-site dev --push
92+
- run: PYTHONPATH="$PWD${PYTHONPATH:+:${PYTHONPATH}}" uv run mike deploy -b docs-site dev --push
9693
if: github.ref == 'refs/heads/main'
9794

9895
- if: github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')
@@ -102,7 +99,7 @@ jobs:
10299
version_file_path: 'pydantic/version.py'
103100
skip_env_check: true
104101

105-
- run: uv run mike deploy -b docs-site ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest --update-aliases --push
102+
- run: PYTHONPATH="$PWD${PYTHONPATH:+:${PYTHONPATH}}" uv run mike deploy -b docs-site ${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest --update-aliases --push
106103
if: ${{ (github.ref == 'refs/heads/docs-update' || startsWith(github.ref, 'refs/tags/')) && !fromJSON(steps.check-version.outputs.IS_PRERELEASE) }}
107104
env:
108105
PYDANTIC_VERSION: v${{ steps.check-version.outputs.VERSION }}

build-docs.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ python3 -m uv run python -c 'import docs.plugins.main'
1616
# pydantic_core/core_schema.py
1717
# instead of
1818
# .venv/lib/python3.10/site-packages/pydantic_core/core_schema.py
19+
# See also: mkdocs.yml:mkdocstrings:handlers:python:paths: [.]:
1920
ln -s .venv/lib/python*/site-packages/pydantic_core pydantic_core
2021
ln -s .venv/lib/python*/site-packages/pydantic_settings pydantic_settings
2122
ln -s .venv/lib/python*/site-packages/pydantic_extra_types pydantic_extra_types
22-
23-
python3 -m uv run --no-sync mkdocs build
23+
# Put these at the front of PYTHONPATH (otherwise, symlinked
24+
# entries will still have "Source code in .venv/lib/.../*.py ":
25+
PYTHONPATH="$PWD${PYTHONPATH:+:${PYTHONPATH}}" python3 -m uv run --no-sync mkdocs build

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ plugins:
244244
- mkdocstrings:
245245
handlers:
246246
python:
247-
paths: [.]
247+
paths: [.] # see also: build-docs.sh
248248
options:
249249
members_order: source
250250
separate_signature: true

0 commit comments

Comments
 (0)