Skip to content

Commit 7857878

Browse files
authored
Merge pull request #2034 from weaviate/docs/suppress-overload-stacking
docs: suppress @typing.overload signature stacking
2 parents e75a914 + 4bbdccc commit 7857878

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

docs/PUBLISHING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Documentation Publishing
2+
3+
How the reference docs at https://weaviate-python-client.readthedocs.io/ are built, how the `weaviate-agents-python-client` is folded in, and how to publish a staging preview for a branch.
4+
5+
For authoring guidance (adding modules, regenerating `.rst` files, building locally), see [README.rst](./README.rst).
6+
7+
## What publishes the docs
8+
9+
Read the Docs (RTD), not GitHub Actions. RTD is configured to watch this repo and rebuild on every push to a tracked branch or tag. The CI workflow at `.github/workflows/main.yaml` only runs `python -m sphinx ...` as a sanity check — it never publishes anything.
10+
11+
Project dashboard: https://readthedocs.org/projects/weaviate-python-client/
12+
13+
## Build configuration
14+
15+
Two files control the build:
16+
17+
- **`.readthedocs.yaml`** — RTD build config (Python version, `pre_build` hooks, requirements file, Sphinx entry point).
18+
- **`docs/conf.py`** — Sphinx config (extensions, theme, autodoc behavior, docstring post-processing).
19+
20+
Build steps RTD runs, in order:
21+
22+
1. Spin up an Ubuntu 22.04 image with Python 3.12 (per `.readthedocs.yaml`).
23+
2. Run the `pre_build` hook (see next section — this is where the agents client gets pulled in).
24+
3. `pip install -r requirements-devel.txt`.
25+
4. `python -m sphinx -b html docs/ <output>` using `docs/conf.py`.
26+
5. Publish the HTML to `https://weaviate-python-client.readthedocs.io/en/<version-slug>/`.
27+
28+
## How the agents client is folded in
29+
30+
The `weaviate-agents-python-client` lives in its own repo (https://github.com/weaviate/weaviate-agents-python-client) but its API reference is published as part of the same RTD site.
31+
32+
This is wired up in `.readthedocs.yaml` via a `pre_build` hook:
33+
34+
```yaml
35+
build:
36+
jobs:
37+
pre_build:
38+
- git clone -b main --depth=1 https://github.com/weaviate/weaviate-agents-python-client.git docs/weaviate-agents-python-client
39+
- python -m pip install -e ./docs/weaviate-agents-python-client
40+
```
41+
42+
And `docs/conf.py` adds the cloned directory to `sys.path`:
43+
44+
```python
45+
sys.path.insert(0, os.path.abspath("weaviate-agents-python-client"))
46+
```
47+
48+
Implications:
49+
50+
- The agents docs always come from the agents repo's `main` branch — pinning to a tag would require editing `.readthedocs.yaml`.
51+
- Changes merged to the agents repo's `main` are **not** automatically published here. The published version updates when either (a) a new release of `weaviate-python-client` is cut, or (b) a maintainer manually triggers a rebuild from the RTD dashboard.
52+
- The agents repo has its own `docs/` tree (with its own `index.rst`, etc.). After cloning, RTD's Sphinx build picks up those `.rst` files because they sit under `docs/weaviate-agents-python-client/docs/`, which Sphinx walks as part of the source tree.
53+
54+
## Publishing a staging build for a branch
55+
56+
Add the branch as a Version in RTD:
57+
58+
1. Open https://readthedocs.org/projects/weaviate-python-client/versions/.
59+
2. Click **+ Add version**, pick the branch from the dropdown (hit the refresh icon if it's not listed yet — RTD polls GitHub for new branches).
60+
3. Tick **Active**. Leave **Hidden** ticked if you don't want the branch to show up in the version switcher on the public site (you'll still get a direct URL).
61+
4. Click **Update version**. RTD kicks off a build immediately.
62+
63+
Watch the build on the **Builds** tab. Once it succeeds, the preview is at:
64+
65+
```
66+
https://weaviate-python-client.readthedocs.io/en/<branch-slug>/
67+
```
68+
69+
RTD slugifies the branch name — slashes become dashes (e.g. `docs/suppress-overload-stacking` → `docs-suppress-overload-stacking`).
70+
71+
When you're done, deactivate the version on the same page so it stops rebuilding on every push to that branch.

docs/conf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ def chdir(directory):
9292
"autosectionlabel",
9393
]
9494

95+
# Suppress @typing.overload signature expansion: render only the implementation
96+
# signature, otherwise autodoc stacks every overload variant with full type hints.
97+
from sphinx.pycode import ModuleAnalyzer as _ModuleAnalyzer
98+
99+
_orig_analyze = _ModuleAnalyzer.analyze
100+
101+
102+
def _analyze_without_overloads(self):
103+
_orig_analyze(self)
104+
self.overloads = {}
105+
106+
107+
_ModuleAnalyzer.analyze = _analyze_without_overloads
108+
95109
# -- Options for HTML output -------------------------------------------------
96110

97111
# The theme to use for HTML and HTML Help pages. See the documentation for

0 commit comments

Comments
 (0)