Unverified Commit a7e93c15 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

DOC Fix sphinx warnings and turn warnings into errors (#1247)

parent 0f89dfaf
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# #
# You can set these variables from the command line. # You can set these variables from the command line.
SPHINXOPTS = SPHINXOPTS = -W # converts warnings into error
SPHINXBUILD = sphinx-build SPHINXBUILD = sphinx-build
SPHINXPROJ = torchaudio SPHINXPROJ = torchaudio
SOURCEDIR = source SOURCEDIR = source
......
...@@ -157,12 +157,12 @@ You can switch from another backend to the ``"soundfile"`` backend with the foll ...@@ -157,12 +157,12 @@ You can switch from another backend to the ``"soundfile"`` backend with the foll
If you are switching from `"soundfile" (legacy interface) <soundfile_legacy_backend>` backend, set ``torchaudio.USE_SOUNDFILE_LEGACY_INTERFACE`` flag **before** switching the backend. If you are switching from `"soundfile" (legacy interface) <soundfile_legacy_backend>` backend, set ``torchaudio.USE_SOUNDFILE_LEGACY_INTERFACE`` flag **before** switching the backend.
info info
^^^^ ----
.. autofunction:: torchaudio.backend._soundfile_backend.info .. autofunction:: torchaudio.backend._soundfile_backend.info
load load
^^^^ ----
.. autofunction:: torchaudio.backend._soundfile_backend.load .. autofunction:: torchaudio.backend._soundfile_backend.load
...@@ -170,7 +170,7 @@ load ...@@ -170,7 +170,7 @@ load
save save
^^^^ ----
.. autofunction:: torchaudio.backend._soundfile_backend.save .. autofunction:: torchaudio.backend._soundfile_backend.save
......
...@@ -58,6 +58,8 @@ delimiters : [ ...@@ -58,6 +58,8 @@ delimiters : [
''' '''
napoleon_use_ivar = True napoleon_use_ivar = True
napoleon_numpy_docstring = False
napoleon_google_docstring = True
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ['_templates']
......
...@@ -44,6 +44,7 @@ def deprecated(direction: str, version: Optional[str] = None): ...@@ -44,6 +44,7 @@ def deprecated(direction: str, version: Optional[str] = None):
direction: Migration steps to be given to users. direction: Migration steps to be given to users.
""" """
def decorator(func): def decorator(func):
@wraps(func) @wraps(func)
def wrapped(*args, **kwargs): def wrapped(*args, **kwargs):
message = ( message = (
......
from typing import Any, Optional from typing import Any, Optional
import warnings
from torchaudio._internal import module_utils as _mod_utils
class AudioMetaData: class AudioMetaData:
...@@ -31,7 +30,6 @@ class AudioMetaData: ...@@ -31,7 +30,6 @@ class AudioMetaData:
self.encoding = encoding self.encoding = encoding
@_mod_utils.deprecated('Please migrate to `AudioMetaData`.', '0.9.0')
class SignalInfo: class SignalInfo:
"""One of return types of ``torchaudio.info`` functions. """One of return types of ``torchaudio.info`` functions.
...@@ -51,13 +49,18 @@ class SignalInfo: ...@@ -51,13 +49,18 @@ class SignalInfo:
rate: Optional[float] = None, rate: Optional[float] = None,
precision: Optional[int] = None, precision: Optional[int] = None,
length: Optional[int] = None) -> None: length: Optional[int] = None) -> None:
message = (
f'{self.__module__}.{self.__class__.__name__} has been deprecated '
'and will be removed from 0.9.0 release. '
'Please migrate to `AudioMetaData`.'
)
warnings.warn(message)
self.channels = channels self.channels = channels
self.rate = rate self.rate = rate
self.precision = precision self.precision = precision
self.length = length self.length = length
@_mod_utils.deprecated('Please migrate to `AudioMetaData`.', '0.9.0')
class EncodingInfo: class EncodingInfo:
"""One of return types of ``torchaudio.info`` functions. """One of return types of ``torchaudio.info`` functions.
...@@ -82,6 +85,12 @@ class EncodingInfo: ...@@ -82,6 +85,12 @@ class EncodingInfo:
reverse_nibbles: Any = None, reverse_nibbles: Any = None,
reverse_bits: Any = None, reverse_bits: Any = None,
opposite_endian: Optional[bool] = None) -> None: opposite_endian: Optional[bool] = None) -> None:
message = (
f'{self.__module__}.{self.__class__.__name__} has been deprecated '
'and will be removed from 0.9.0 release. '
'Please migrate to `AudioMetaData`.'
)
warnings.warn(message)
self.encoding = encoding self.encoding = encoding
self.bits_per_sample = bits_per_sample self.bits_per_sample = bits_per_sample
self.compression = compression self.compression = compression
......
...@@ -22,18 +22,22 @@ def info( ...@@ -22,18 +22,22 @@ def info(
filepath (path-like object or file-like object): filepath (path-like object or file-like object):
Source of audio data. When the function is not compiled by TorchScript, Source of audio data. When the function is not compiled by TorchScript,
(e.g. ``torch.jit.script``), the following types are accepted; (e.g. ``torch.jit.script``), the following types are accepted;
* ``path-like``: file path * ``path-like``: file path
* ``file-like``: Object with ``read(size: int) -> bytes`` method, * ``file-like``: Object with ``read(size: int) -> bytes`` method,
which returns byte string of at most ``size`` length. which returns byte string of at most ``size`` length.
When the function is compiled by TorchScript, only ``str`` type is allowed. When the function is compiled by TorchScript, only ``str`` type is allowed.
Note: Note:
* When the input type is file-like object, this function cannot * When the input type is file-like object, this function cannot
get the correct length (``num_samples``) for certain formats, get the correct length (``num_samples``) for certain formats,
such as ``mp3`` and ``vorbis``. such as ``mp3`` and ``vorbis``.
In this case, the value of ``num_samples`` is ``0``. In this case, the value of ``num_samples`` is ``0``.
* This argument is intentionally annotated as ``str`` only due to * This argument is intentionally annotated as ``str`` only due to
TorchScript compiler compatibility. TorchScript compiler compatibility.
format (str, optional): format (str, optional):
Override the format detection with the given format. Override the format detection with the given format.
Providing the argument might help when libsox can not infer the format Providing the argument might help when libsox can not infer the format
...@@ -103,14 +107,15 @@ def load( ...@@ -103,14 +107,15 @@ def load(
filepath (path-like object or file-like object): filepath (path-like object or file-like object):
Source of audio data. When the function is not compiled by TorchScript, Source of audio data. When the function is not compiled by TorchScript,
(e.g. ``torch.jit.script``), the following types are accepted; (e.g. ``torch.jit.script``), the following types are accepted;
* ``path-like``: file path * ``path-like``: file path
* ``file-like``: Object with ``read(size: int) -> bytes`` method, * ``file-like``: Object with ``read(size: int) -> bytes`` method,
which returns byte string of at most ``size`` length. which returns byte string of at most ``size`` length.
When the function is compiled by TorchScript, only ``str`` type is allowed. When the function is compiled by TorchScript, only ``str`` type is allowed.
Note: Note: This argument is intentionally annotated as ``str`` only due to
* This argument is intentionally annotated as ``str`` only due to TorchScript compiler compatibility.
TorchScript compiler compatibility.
frame_offset (int): frame_offset (int):
Number of frames to skip before start reading data. Number of frames to skip before start reading data.
num_frames (int): num_frames (int):
......
...@@ -173,14 +173,16 @@ def apply_effects_file( ...@@ -173,14 +173,16 @@ def apply_effects_file(
Args: Args:
path (path-like object or file-like object): path (path-like object or file-like object):
Source of audio data. When the function is not compiled by TorchScript, Source of audio data. When the function is not compiled by TorchScript,
(e.g. ``torch.jit.script``), the following types are accepted; (e.g. ``torch.jit.script``), the following types are accepted:
* ``path-like``: file path * ``path-like``: file path
* ``file-like``: Object with ``read(size: int) -> bytes`` method, * ``file-like``: Object with ``read(size: int) -> bytes`` method,
which returns byte string of at most ``size`` length. which returns byte string of at most ``size`` length.
When the function is compiled by TorchScript, only ``str`` type is allowed. When the function is compiled by TorchScript, only ``str`` type is allowed.
Note:
* This argument is intentionally annotated as ``str`` only for Note: This argument is intentionally annotated as ``str`` only for
TorchScript compiler compatibility. TorchScript compiler compatibility.
effects (List[List[str]]): List of effects. effects (List[List[str]]): List of effects.
normalize (bool): normalize (bool):
When ``True``, this function always return ``float32``, and sample values are When ``True``, this function always return ``float32``, and sample values are
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment