Skip to content

Commit 1fe4470

Browse files
committed
Document method parameters and use sphinx-autodoc-typehints in docs
1 parent f865e04 commit 1fe4470

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

discid/disc.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def read(
3737
"""Reads the TOC from the device given as string
3838
and returns a :class:`Disc` object.
3939
40-
That string can be either of :obj:`str <python:str>` or :obj:`bytes`.
40+
The device string can be either of :obj:`str <python:str>` or :obj:`bytes`.
4141
However, it should in no case contain non-ASCII characters.
4242
If no device is given, a default, also given by :func:`get_default_device`
4343
is used.
@@ -50,6 +50,9 @@ def read(
5050
A :exc:`DiscError` exception is raised when the reading fails,
5151
and :exc:`NotImplementedError` when libdiscid doesn't support
5252
reading discs on the current platform.
53+
54+
:param device: the device name to use or :obj:`None` for using the default device
55+
:param features: list of features to enable ("read" will always be assumed)
5356
"""
5457
disc = Disc()
5558
disc.read(device, features)
@@ -60,17 +63,18 @@ def put(first: int, last: int, disc_sectors: int, track_offsets: list[int]) -> "
6063
"""Creates a TOC based on the information given
6164
and returns a :class:`Disc` object.
6265
63-
Takes the `first` track and `last` **audio** track as :obj:`int`.
64-
`disc_sectors` is the end of the last audio track,
65-
normally the total sector count of the disc.
66-
`track_offsets` is a list of all audio track offsets.
67-
6866
Depending on how you get the total sector count,
6967
you might have to subtract 11400 (2:32 min.) for discs with data tracks.
7068
7169
A :exc:`TOCError` exception is raised when illegal parameters
7270
are provided.
7371
72+
:param first: number of the first audio track
73+
:param last: number of the last audio track
74+
:param disc_sectors: the end of the last audio track, normally the total
75+
sector count of the disc
76+
:param track_offsets: list of all audio track offsets
77+
7478
.. seealso:: :musicbrainz:`Disc ID Calculation`
7579
"""
7680
disc = Disc()

discid/track.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828

2929

3030
class Track(object):
31-
"""Track objects are part of the :class:`Disc` class."""
31+
"""Track objects are part of the :class:`Disc` class.
32+
33+
:param disc: the :class:`Disc` object
34+
:param number: the track number
35+
"""
3236

3337
def __init__(self, disc: "Disc", number: int):
3438
self._disc = disc
@@ -98,7 +102,7 @@ def seconds(self) -> int:
98102
def isrc(self) -> str | None:
99103
"""The International Standard Recording Code
100104
101-
This will be `None` when the `"isrc"` feature was not requested
105+
This will be :obj:`None` when the `"isrc"` feature was not requested
102106
or not supported, otherwise this is a :obj:`str <python:str>` object.
103107
"""
104108
return self._get_track_isrc()

doc/conf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ def __getattr__(cls, name):
2727

2828
extensions = [
2929
"sphinx.ext.autodoc",
30+
"sphinx.ext.autosummary",
3031
"sphinx.ext.coverage",
3132
"sphinx.ext.extlinks",
3233
"sphinx.ext.intersphinx",
34+
"sphinx_autodoc_typehints",
3335
]
3436
source_suffix = ".rst"
3537
master_doc = "index"
36-
exclude_patterns = ["_build"]
38+
exclude_patterns = ["_build", ".venv"]
3739

3840
# General information about the project.
3941
project = "python-discid"

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ Changelog = "https://github.com/metabrainz/python-discid/blob/master/CHANGES.rst
3333
[dependency-groups]
3434
test = ["pytest"]
3535
docs = [
36-
"Sphinx~=8.1.3",
37-
"sphinx-rtd-theme~=3.0.2",
36+
"Sphinx>=8.1.3",
37+
"sphinx-autodoc-typehints>=3.0.1",
38+
"sphinx-rtd-theme>=3.0.2",
3839
]
3940
dev = [
4041
"pre-commit>=4.5.1",

0 commit comments

Comments
 (0)