Skip to content

Commit a9d02a4

Browse files
committed
Updated docs.
1 parent 5ba086d commit a9d02a4

23 files changed

+324
-154
lines changed

.isort.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ known_third_party =
2121
faker
2222
github
2323
importlib_resources
24+
iniconfig
2425
pandas
2526
pydash
2627
pytest

doc-source/api/dates.rst

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,33 @@
1212

1313
.. automodule:: domdf_python_tools.dates
1414
:undoc-members:
15+
:exclude-members: months
1516

16-
.. py:data:: months
17+
**Data:**
1718

18-
Mapping of months to their 3-character shortcodes.
19+
.. autosummary::
1920

20-
Essentially:
21+
~domdf_python_tools.dates.months
2122

22-
.. code-block:: python
2323

24-
months = {
25-
Jan="January",
26-
Feb="February",
27-
Mar="March",
28-
Apr="April",
29-
May="May",
30-
Jun="June",
31-
Jul="July",
32-
Aug="August",
33-
Sep="September",
34-
Oct="October",
35-
Nov="November",
36-
Dec="December",
37-
}
24+
.. autovariable:: domdf_python_tools.dates.months
25+
:no-value:
26+
27+
Essentially:
28+
29+
.. code-block:: python
30+
31+
months = {
32+
Jan="January",
33+
Feb="February",
34+
Mar="March",
35+
Apr="April",
36+
May="May",
37+
Jun="June",
38+
Jul="July",
39+
Aug="August",
40+
Sep="September",
41+
Oct="October",
42+
Nov="November",
43+
Dec="December",
44+
}

doc-source/api/delegators.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
=====================================
44

55
.. automodule:: domdf_python_tools.delegators
6+
:members: _C,delegate_kwargs,delegates

doc-source/api/paths.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
.. automodule:: domdf_python_tools.paths
66
:undoc-members:
7-
:exclude-members: __enter__,__exit__
7+
:exclude-members: __enter__,__exit__,__slots__

doc-source/api/words.rst

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
:mod:`domdf_python_tools.words`
33
=================================
44

5-
Functions for working with (English) words.
6-
7-
.. versionadded:: 0.4.5
5+
.. automodule:: domdf_python_tools.words
6+
:no-members:
87

98
.. automodulesumm:: domdf_python_tools.words
109

11-
.. autodata:: domdf_python_tools.words.ascii_digits
12-
.. autodata:: domdf_python_tools.words.greek_uppercase
13-
.. autodata:: domdf_python_tools.words.greek_lowercase
10+
.. autovariable:: domdf_python_tools.words.ascii_digits
11+
.. autovariable:: domdf_python_tools.words.greek_uppercase
12+
.. autovariable:: domdf_python_tools.words.greek_lowercase
1413

1514
.. autofunction:: domdf_python_tools.words.get_words_list
1615
.. autofunction:: domdf_python_tools.words.get_random_word
@@ -19,38 +18,49 @@ Functions for working with (English) words.
1918
.. autoclass:: domdf_python_tools.words.Font
2019
:special-members:
2120

22-
.. autodata:: domdf_python_tools.words.SERIF_BOLD_LETTERS
23-
:annotation:
21+
.. autovariable:: domdf_python_tools.words.SERIF_BOLD_LETTERS
22+
:no-value:
23+
:no-type:
2424

25-
.. autodata:: domdf_python_tools.words.SERIF_ITALIC_LETTERS
26-
:annotation:
25+
.. autovariable:: domdf_python_tools.words.SERIF_ITALIC_LETTERS
26+
:no-value:
27+
:no-type:
2728

28-
.. autodata:: domdf_python_tools.words.SERIF_BOLD_ITALIC_LETTERS
29-
:annotation:
29+
.. autovariable:: domdf_python_tools.words.SERIF_BOLD_ITALIC_LETTERS
30+
:no-value:
31+
:no-type:
3032

31-
.. autodata:: domdf_python_tools.words.SANS_SERIF_LETTERS
32-
:annotation:
33+
.. autovariable:: domdf_python_tools.words.SANS_SERIF_LETTERS
34+
:no-value:
35+
:no-type:
3336

34-
.. autodata:: domdf_python_tools.words.SANS_SERIF_BOLD_LETTERS
35-
:annotation:
37+
.. autovariable:: domdf_python_tools.words.SANS_SERIF_BOLD_LETTERS
38+
:no-value:
39+
:no-type:
3640

37-
.. autodata:: domdf_python_tools.words.SANS_SERIF_ITALIC_LETTERS
38-
:annotation:
41+
.. autovariable:: domdf_python_tools.words.SANS_SERIF_ITALIC_LETTERS
42+
:no-value:
43+
:no-type:
3944

40-
.. autodata:: domdf_python_tools.words.SANS_SERIF_BOLD_ITALIC_LETTERS
41-
:annotation:
45+
.. autovariable:: domdf_python_tools.words.SANS_SERIF_BOLD_ITALIC_LETTERS
46+
:no-value:
47+
:no-type:
4248

43-
.. autodata:: domdf_python_tools.words.SCRIPT_LETTERS
44-
:annotation:
49+
.. autovariable:: domdf_python_tools.words.SCRIPT_LETTERS
50+
:no-value:
51+
:no-type:
4552

46-
.. autodata:: domdf_python_tools.words.FRAKTUR_LETTERS
47-
:annotation:
53+
.. autovariable:: domdf_python_tools.words.FRAKTUR_LETTERS
54+
:no-value:
55+
:no-type:
4856

49-
.. autodata:: domdf_python_tools.words.MONOSPACE_LETTERS
50-
:annotation:
57+
.. autovariable:: domdf_python_tools.words.MONOSPACE_LETTERS
58+
:no-value:
59+
:no-type:
5160

52-
.. autodata:: domdf_python_tools.words.DOUBLESTRUCK_LETTERS
53-
:annotation:
61+
.. autovariable:: domdf_python_tools.words.DOUBLESTRUCK_LETTERS
62+
:no-value:
63+
:no-type:
5464

5565
.. autofunction:: domdf_python_tools.words.as_text
5666

doc-source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from __pkginfo__ import __version__
1818

1919
domdf_python_tools.__docs = True
20-
overloads_location = "bottom"
2120

2221
github_username = "domdfcoding"
2322
github_repository = "domdf_python_tools"
@@ -73,6 +72,7 @@
7372
'rtd': ('https://docs.readthedocs.io/en/latest/', None),
7473
"h5py": ('https://docs.h5py.org/en/latest/', None),
7574
"sarge": ('https://sarge.readthedocs.io/en/latest/', None),
75+
'pandas': ('https://pandas.pydata.org/docs/', None),
7676
}
7777

7878
html_theme = 'domdf_sphinx_theme'

domdf_python_tools/bases.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@
5151
# 3rd party
5252
import pydash # type: ignore
5353

54-
__all__ = ["Dictable", "NamedList", "namedlist", "UserList"]
55-
5654
# this package
5755
from domdf_python_tools.doctools import prettify_docstrings
5856

57+
__all__ = ["Dictable", "NamedList", "namedlist", "UserList"]
58+
59+
_V = TypeVar("_V")
60+
5961

60-
class Dictable(Iterable):
62+
@prettify_docstrings
63+
class Dictable(Iterable[Tuple[str, _V]]):
6164
"""
6265
The basic structure of a class that can be converted into a dictionary.
6366
"""
@@ -66,13 +69,20 @@ class Dictable(Iterable):
6669
def __init__(self, *args, **kwargs):
6770
pass
6871

72+
def __repr__(self) -> str:
73+
return super().__repr__()
74+
6975
def __str__(self) -> str:
7076
return self.__repr__()
7177

72-
def __iter__(self) -> Iterable[Tuple[str, Any]]: # type: ignore[override]
78+
def __iter__(self) -> Iterator[Tuple[str, _V]]:
79+
"""
80+
Iterate over the attributes of the class.
81+
"""
82+
7383
yield from self.__dict__.items()
7484

75-
def __getstate__(self) -> Dict[str, Any]:
85+
def __getstate__(self) -> Dict[str, _V]:
7686
return self.__dict__
7787

7888
def __setstate__(self, state):

domdf_python_tools/dates.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
# stdlib
3434
import datetime
35+
import sys
36+
import typing
3537
from collections import OrderedDict
3638
from typing import Optional, Union
3739

@@ -110,8 +112,6 @@ def get_timezone(tz: str, date: Optional[datetime.datetime] = None) -> Optional[
110112
def current_tzinfo() -> Optional[datetime.tzinfo]:
111113
"""
112114
Returns a tzinfo object for the current timezone.
113-
114-
:rtype: :class:`python:datetime.tzinfo`
115115
"""
116116

117117
return datetime.datetime.now().astimezone().tzinfo # pragma: no cover (hard to test)
@@ -126,7 +126,7 @@ def current_tzinfo() -> Optional[datetime.tzinfo]:
126126
# :type datetime: :class:`datetime.datetime`
127127
# :param current_tzinfo: A tzinfo object representing the current timezone.
128128
# If None it will be inferred.
129-
# :type current_tzinfo: :class:`~python:datetime.tzinfo`
129+
# :type current_tzinfo: :class:`datetime.tzinfo`
130130
#
131131
# :return: Timestamp in UTC timezone
132132
# :rtype: float
@@ -140,12 +140,10 @@ def set_timezone(obj: datetime.datetime, tzinfo: datetime.tzinfo) -> datetime.da
140140
"""
141141
Sets the timezone / tzinfo of the given :class:`datetime.datetime` object.
142142
This will not convert the time (i.e. the hours will stay the same).
143-
Use :meth:`python:datetime.datetime.astimezone` to accomplish that.
143+
Use :meth:`datetime.datetime.astimezone` to accomplish that.
144144
145145
:param obj:
146146
:param tzinfo:
147-
148-
:return:
149147
"""
150148

151149
return obj.replace(tzinfo=tzinfo)
@@ -161,7 +159,7 @@ def utc_timestamp_to_datetime(
161159
If ``output_tz`` is None the timestamp is converted to the platform’s local date and time,
162160
and the local timezone is inferred and set for the object.
163161
164-
If ``output_tz`` is not None, it must be an instance of a :class:`~python:datetime.tzinfo` subclass,
162+
If ``output_tz`` is not None, it must be an instance of a :class:`datetime.tzinfo` subclass,
165163
and the timestamp is converted to ``output_tz``’s time zone.
166164
167165
@@ -171,7 +169,7 @@ def utc_timestamp_to_datetime(
171169
172170
:return: The timestamp as a datetime object.
173171
174-
:raises: :class:`~python:OverflowError` if the timestamp is out of the range
172+
:raises OverflowError: if the timestamp is out of the range
175173
of values supported by the platform C localtime() or gmtime() functions,
176174
and OSError on localtime() or gmtime() failure. It’s common for this to
177175
be restricted to years in 1970 through 2038.
@@ -181,8 +179,13 @@ def utc_timestamp_to_datetime(
181179
return new_datetime.astimezone(output_tz)
182180

183181

184-
# Mapping of months to their 3-character shortcodes.
185-
months = OrderedDict(
182+
if sys.version_info <= (3, 7):
183+
MonthsType = OrderedDict
184+
else:
185+
MonthsType = typing.OrderedDict[str, str]
186+
187+
#: Mapping of 3-character shortcodes to full month names.
188+
months: MonthsType = OrderedDict(
186189
Jan="January",
187190
Feb="February",
188191
Mar="March",

domdf_python_tools/doctools.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
from typing import Any, Callable, Dict, Optional, Sequence, Type, TypeVar, Union
3535

3636
# this package
37-
from domdf_python_tools.stringlist import StringList
3837
from domdf_python_tools.typing import MethodDescriptorType, MethodWrapperType, WrapperDescriptorType
3938

4039
__all__ = [
@@ -99,6 +98,9 @@ def append_doctring_from_another(target: Union[Type, Callable], original: Union[
9998
:param original: The object to copy the docstring from
10099
"""
101100

101+
# this package
102+
from domdf_python_tools.stringlist import StringList
103+
102104
target_doc = target.__doc__
103105
original_doc = original.__doc__
104106

@@ -129,7 +131,7 @@ def make_sphinx_links(input_string: str, builtins_list: Optional[Sequence[str]]
129131
130132
.. code-block:: rest
131133
132-
:class:`~python:str`
134+
:class:`str`
133135
134136
Make sure to have ``'python': ('https://docs.python.org/3/', None),`` in the
135137
``intersphinx_mapping`` dict of your ``conf.py`` file for Sphinx.
@@ -147,7 +149,7 @@ def make_sphinx_links(input_string: str, builtins_list: Optional[Sequence[str]]
147149
working_string = f"{input_string}"
148150

149151
for builtin in {x for x in builtins_list if not x.startswith("__") and x != "None"}:
150-
working_string = working_string.replace(f"``{builtin}``", f":class:`~python:{builtin}`")
152+
working_string = working_string.replace(f"``{builtin}``", f":class:`{builtin}`")
151153

152154
return working_string
153155

@@ -185,7 +187,7 @@ def wrapper(target: F) -> F:
185187
return wrapper
186188

187189

188-
def sphinxify_docstring() -> Callable:
190+
def sphinxify_docstring() -> Callable[[F], F]:
189191
r"""
190192
Decorator to make proper sphinx links out of double-backticked strings in the docstring.
191193
@@ -199,7 +201,7 @@ def sphinxify_docstring() -> Callable:
199201
200202
.. code-block:: rest
201203
202-
:class:`~python:str`
204+
:class:`str`
203205
204206
Make sure to have ``'python': ('https://docs.python.org/3/', None),`` in the
205207
``intersphinx_mapping`` dict of your ``conf.py`` file for Sphinx.
@@ -345,11 +347,11 @@ def _do_prettify(obj: Type, base: Type, new_docstrings: Dict[str, str]):
345347

346348
def prettify_docstrings(obj: Type) -> Type:
347349
"""
348-
Prettify the default :class:`object` docstrings for use in Sphinx documentation.
350+
Decorator to prettify the default :class:`object` docstrings for use in Sphinx documentation.
349351
350352
:param obj: The object to prettify the method docstrings for.
351353
352-
:return: The object
354+
:rtype:
353355
354356
.. versionadded:: 0.8.0
355357
"""

0 commit comments

Comments
 (0)