Repository navigation
[doc] Render API type hints in both the signature and the Parameters list - #64778
Conversation
…list `autodoc_typehints` was set to "signature", so the description-side Parameters list showed only a name and prose for each parameter, with the types available solely in the class or function signature above. Surfacing the type alongside each parameter description makes the reference easier to scan and easier for tools that read the description list to parse. Switch `autodoc_typehints` to "both" and add `autodoc_typehints_description_target = "documented"`. The signature keeps its short type names unchanged; the Parameters list now shows `name (ShortType) - description`. The "documented" target is required: with the default "all" target, "both" mode drops the parameter descriptions and renders verbose typing spellings (Optional[...], Union[...]) instead of the short PEP 604 names. Signed-off-by: Douglas Strodtman <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the Sphinx configuration in doc/source/conf.py to display type hints in both the signature and the parameters description list by setting autodoc_typehints to 'both' and autodoc_typehints_description_target to 'documented'. I have no feedback to provide.
|
Companion proposal: #64779 takes the alternative "move information" approach — it removes types from the signature and shows them only in the Parameters list ( |
|
Planning to close as superseded by #64779; will wait on final decision. |
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
…list (ray-project#64778) ## Why this change API reference pages set `autodoc_typehints = "signature"`, so each parameter's type appeared only in the signature. The Parameters description list showed just a name and prose. Surfacing the type alongside each description makes the reference easier to scan, and easier for tools that read the description list. ## What changed `doc/source/conf.py`: `autodoc_typehints = "both"` plus `autodoc_typehints_description_target = "documented"`. The signature keeps its existing short type names; the Parameters list now shows `name (ShortType) - description`. The `"documented"` target is load-bearing: with the default `"all"` target, `"both"` drops the parameter descriptions and renders verbose `Optional[...]`/ `Union[...]` spellings instead of the short PEP 604 names. ## Not a duplicate No open PR or issue touches `autodoc_typehints` / `autodoc_typehints_description_target` (checked `gh pr list` / `gh issue list` on ray-project/ray). ## Testing Full RtD-faithful clean build with warnings-as-errors: `make rtd-build` (Sphinx 8.2.3, `-a -E -W --keep-going`, 3970 docs) -> `build succeeded`, exit 0, zero Sphinx warnings. Since the docs build runs `fail_on_warning: true`, a clean `-W` build here means clean on RtD. Rendered-output spot checks in the built HTML: - `TorchTrainer` (class): signature short types unchanged; Parameters list now `train_loop_config (Dict | None) - ...`. - `ScalingConfig` (dataclass): `num_workers (int | Tuple[int, int]) - ...`. - `read_parquet` (function): Parameters gain short types; `Return type: Dataset` unchanged. - `AutoscalingConfig` (pydantic model): rendered by autodoc_pydantic, unaffected. ## AI assistance This change was prepared with AI assistance (Claude Code). The change and its verification were reviewed by the submitter. Signed-off-by: Douglas Strodtman <[email protected]>
…list (ray-project#64778) ## Why this change API reference pages set `autodoc_typehints = "signature"`, so each parameter's type appeared only in the signature. The Parameters description list showed just a name and prose. Surfacing the type alongside each description makes the reference easier to scan, and easier for tools that read the description list. ## What changed `doc/source/conf.py`: `autodoc_typehints = "both"` plus `autodoc_typehints_description_target = "documented"`. The signature keeps its existing short type names; the Parameters list now shows `name (ShortType) - description`. The `"documented"` target is load-bearing: with the default `"all"` target, `"both"` drops the parameter descriptions and renders verbose `Optional[...]`/ `Union[...]` spellings instead of the short PEP 604 names. ## Not a duplicate No open PR or issue touches `autodoc_typehints` / `autodoc_typehints_description_target` (checked `gh pr list` / `gh issue list` on ray-project/ray). ## Testing Full RtD-faithful clean build with warnings-as-errors: `make rtd-build` (Sphinx 8.2.3, `-a -E -W --keep-going`, 3970 docs) -> `build succeeded`, exit 0, zero Sphinx warnings. Since the docs build runs `fail_on_warning: true`, a clean `-W` build here means clean on RtD. Rendered-output spot checks in the built HTML: - `TorchTrainer` (class): signature short types unchanged; Parameters list now `train_loop_config (Dict | None) - ...`. - `ScalingConfig` (dataclass): `num_workers (int | Tuple[int, int]) - ...`. - `read_parquet` (function): Parameters gain short types; `Return type: Dataset` unchanged. - `AutoscalingConfig` (pydantic model): rendered by autodoc_pydantic, unaffected. ## AI assistance This change was prepared with AI assistance (Claude Code). The change and its verification were reviewed by the submitter. Signed-off-by: Douglas Strodtman <[email protected]> Signed-off-by: 400Ping <[email protected]>
…list (ray-project#64778) ## Why this change API reference pages set `autodoc_typehints = "signature"`, so each parameter's type appeared only in the signature. The Parameters description list showed just a name and prose. Surfacing the type alongside each description makes the reference easier to scan, and easier for tools that read the description list. ## What changed `doc/source/conf.py`: `autodoc_typehints = "both"` plus `autodoc_typehints_description_target = "documented"`. The signature keeps its existing short type names; the Parameters list now shows `name (ShortType) - description`. The `"documented"` target is load-bearing: with the default `"all"` target, `"both"` drops the parameter descriptions and renders verbose `Optional[...]`/ `Union[...]` spellings instead of the short PEP 604 names. ## Not a duplicate No open PR or issue touches `autodoc_typehints` / `autodoc_typehints_description_target` (checked `gh pr list` / `gh issue list` on ray-project/ray). ## Testing Full RtD-faithful clean build with warnings-as-errors: `make rtd-build` (Sphinx 8.2.3, `-a -E -W --keep-going`, 3970 docs) -> `build succeeded`, exit 0, zero Sphinx warnings. Since the docs build runs `fail_on_warning: true`, a clean `-W` build here means clean on RtD. Rendered-output spot checks in the built HTML: - `TorchTrainer` (class): signature short types unchanged; Parameters list now `train_loop_config (Dict | None) - ...`. - `ScalingConfig` (dataclass): `num_workers (int | Tuple[int, int]) - ...`. - `read_parquet` (function): Parameters gain short types; `Return type: Dataset` unchanged. - `AutoscalingConfig` (pydantic model): rendered by autodoc_pydantic, unaffected. ## AI assistance This change was prepared with AI assistance (Claude Code). The change and its verification were reviewed by the submitter. Signed-off-by: Douglas Strodtman <[email protected]>
Why this change
API reference pages set
autodoc_typehints = "signature", so each parameter'stype appeared only in the signature. The Parameters description list showed
just a name and prose. Surfacing the type alongside each description makes the
reference easier to scan, and easier for tools that read the description list.
What changed
doc/source/conf.py:autodoc_typehints = "both"plusautodoc_typehints_description_target = "documented". The signature keeps itsexisting short type names; the Parameters list now shows
name (ShortType) - description.The
"documented"target is load-bearing: with the default"all"target,"both"drops the parameter descriptions and renders verboseOptional[...]/Union[...]spellings instead of the short PEP 604 names.Not a duplicate
No open PR or issue touches
autodoc_typehints/autodoc_typehints_description_target(checkedgh pr list/gh issue liston ray-project/ray).
Testing
Full RtD-faithful clean build with warnings-as-errors:
make rtd-build(Sphinx 8.2.3,-a -E -W --keep-going, 3970 docs) ->build succeeded, exit 0, zero Sphinx warnings. Since the docs build runsfail_on_warning: true, a clean-Wbuild here means clean on RtD.Rendered-output spot checks in the built HTML:
TorchTrainer(class): signature short types unchanged; Parameters list nowtrain_loop_config (Dict | None) - ....ScalingConfig(dataclass):num_workers (int | Tuple[int, int]) - ....read_parquet(function): Parameters gain short types;Return type: Datasetunchanged.
AutoscalingConfig(pydantic model): rendered by autodoc_pydantic, unaffected.AI assistance
This change was prepared with AI assistance (Claude Code). The change and its
verification were reviewed by the submitter.