Skip to content

Remove legacy Sphinx roles from docstrings#8016

Open
Pchambet wants to merge 1 commit intohuggingface:mainfrom
Pchambet:fix/remove-legacy-sphinx-roles
Open

Remove legacy Sphinx roles from docstrings#8016
Pchambet wants to merge 1 commit intohuggingface:mainfrom
Pchambet:fix/remove-legacy-sphinx-roles

Conversation

@Pchambet
Copy link

Summary

Replace all remaining :obj:, :class:, :func:, and :meth: Sphinx cross-reference roles with plain backtick references, aligning with the project's current documentation conventions.

14 files, 71 replacements. No logic changes.

Context

As noted in #5324, the codebase had a mix of old Sphinx syntax and the modern backtick-only format used by HuggingFace's doc builder. @stevhliu mentioned that the user-facing APIs had been cleaned up, but old syntax was still lingering in non-public APIs. This PR catches the remaining occurrences.

What changed

Old syntax New syntax Count
:obj:\bool`` `bool` 18
:class:\DatasetInfo`` `DatasetInfo` 15
:func:\fsspec.open`` `fsspec.open` 9
:meth:\...`` `...` 2
:obj:\~pathlib.Path`` `Path` 8
:class:\~download.DownloadConfig`` `DownloadConfig` 3
other 16

Tilde references (~module.Class) are resolved to their short name (Class), matching the existing convention in the codebase.

Files touched

src/datasets/arrow_dataset.py
src/datasets/arrow_writer.py
src/datasets/dataset_dict.py
src/datasets/features/features.py
src/datasets/filesystems/compression.py
src/datasets/fingerprint.py
src/datasets/formatting/formatting.py
src/datasets/inspect.py
src/datasets/iterable_dataset.py
src/datasets/load.py
src/datasets/streaming.py
src/datasets/table.py
src/datasets/utils/deprecation_utils.py
src/datasets/utils/file_utils.py

Relates to #5324

Replace :obj:, :class:, :func:, and :meth: Sphinx roles with plain
backtick references to match the project's current documentation
conventions.

Examples of changes:
  :obj:`bool`                          ->  `bool`
  :class:`DatasetInfo`                 ->  `DatasetInfo`
  :func:`fsspec.open`                  ->  `fsspec.open`
  :meth:`datasets.Datasets.select`     ->  `datasets.Datasets.select`
  :obj:`~pathlib.Path`                 ->  `Path`
  :class:`~download.DownloadConfig`    ->  `DownloadConfig`

14 files, 71 replacements. No logic changes.

Relates to huggingface#5324
Copy link
Member

@stevhliu stevhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, thanks for cleaning up! i left a few notes about fixing up the formatting

Comment on lines +1464 to +1465
a `DatasetInfo` that was dumped to a JSON object. This acts as an analogue to
`Features.from_arrow_schema` and handles the recursive field-by-field instantiation, but doesn't require any
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's a dataset class or method, you can use brackets to render it as a link :)

Suggested change
a `DatasetInfo` that was dumped to a JSON object. This acts as an analogue to
`Features.from_arrow_schema` and handles the recursive field-by-field instantiation, but doesn't require any
a [`DatasetInfo`] that was dumped to a JSON object. This acts as an analogue to
[`Features.from_arrow_schema`] and handles the recursive field-by-field instantiation, but doesn't require any

Args:
feature (FeatureType): the feature type to be checked
ignore_decode_attribute (:obj:`bool`, default ``False``): Whether to ignore the current value
ignore_decode_attribute (`bool`, default ``False``): Whether to ignore the current value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ignore_decode_attribute (`bool`, default ``False``): Whether to ignore the current value
ignore_decode_attribute (`bool`, default `False`): Whether to ignore the current value

def keep_features_dicts_synced(func):
"""
Wrapper to keep the secondary dictionary, which tracks whether keys are decodable, of the :class:`datasets.Features` object
Wrapper to keep the secondary dictionary, which tracks whether keys are decodable, of the `datasets.Features` object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the ~ to hide the "datasets" part from rendering in the link

Suggested change
Wrapper to keep the secondary dictionary, which tracks whether keys are decodable, of the `datasets.Features` object
Wrapper to keep the secondary dictionary, which tracks whether keys are decodable, of the [`~datasets.Features`] object

mode (:obj:``str``): Currently, only 'rb' accepted
target_protocol(:obj:``str``, optional): To override the FS protocol inferred from a URL.
target_options (:obj:``dict``, optional): Kwargs passed when instantiating the target FS.
fo (``str``): Path to compressed file. Will fetch file using ``fsspec.open()``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets remove all the double backticks here

Suggested change
fo (``str``): Path to compressed file. Will fetch file using ``fsspec.open()``
fo (`str`): Path to compressed file. Will fetch file using ``fsspec.open()``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants