Skip to content

Commit f4e9f42

Browse files
Merge pull request #37 from davidhozic/develop
* Update readthedocs-sphinx-search requirement in /requirements (#33) Updates the requirements on [readthedocs-sphinx-search](https://github.com/readthedocs/readthedocs-sphinx-search) to permit the latest version. - [Changelog](https://github.com/readthedocs/readthedocs-sphinx-search/blob/main/CHANGELOG.rst) - [Commits](readthedocs/readthedocs-sphinx-search@0.3.2...0.3.2) --- updated-dependencies: - dependency-name: readthedocs-sphinx-search dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * 1.3.1 * feat: Literal and enum list definition (#34) * Iterable literal and singleton definition * docs * Deprecated parameters support (#35) * Deprecated parameters * Better deprecations * Docs * Flag definition (#36) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2 parents 226ede3 + 46d17f2 commit f4e9f42

18 files changed

+522
-100
lines changed

docs/source/changelog.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ v1.3.1
2828
- Fixed :func:`tkclasswiz.convert.convert_objects_to_script` not including enum imports.
2929

3030

31+
v1.4.0
32+
================
33+
- Definition of enums and literal values inside iterable types.
34+
- Ability to register deprecated parameters.
35+
- Ability to define :class:`enum.Flag` like flags.
36+
37+
38+
v1.3.1
39+
================
40+
- Fixed :func:`tkclasswiz.convert.convert_objects_to_script` not including enum imports.
41+
42+
3143
v1.3.0
3244
================
3345
- The types will now have their subscripted type displayed alongside them.

docs/source/guide/defining.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,48 @@ This is how our frame looks after defining 4 ``Wheel`` objects:
172172
:width: 15cm
173173

174174

175+
Defining (enum) flags
176+
=======================
177+
Let's say that our car also needs a type designation. The ``Car`` class may contain an enum flag parameter,
178+
indicating this designation.
179+
180+
.. code-block:: python
181+
182+
from enum import Flag, auto
183+
184+
class Designation(Flag):
185+
FAMILIY = auto()
186+
SINGLE_PERSON = auto()
187+
HEAVY_TRANSPORT = auto()
188+
189+
class Car:
190+
def __init__(
191+
self,
192+
...
193+
designation: Designation,
194+
):
195+
...
196+
197+
When we try to define the ``designation`` parameter from the above example,
198+
the following window will be displayed.
199+
200+
.. image:: ./images/new_define_frame_flag.png
201+
:width: 15cm
202+
203+
The flag definition frame has 4 main elements:
204+
205+
- a placeholder for the current value,
206+
- a Combobox (dropdown menu) for selecting a flag
207+
- an add button for adding the selected (in Combobox) flag to the current flag value.
208+
- a remove button for removing the selected (in Combobox) flag from the current flag value.
209+
210+
The following image shows show two added flags look inside the placeholder.
211+
212+
.. image:: ./images/new_define_frame_flag_values.png
213+
:width: 15cm
214+
215+
The flag value can be saved like any other type. It is done by clicking on the "Save" button.
216+
175217
Final definition
176218
=================
177219

docs/source/guide/deprecations.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
========================
2+
Deprecations
3+
========================
4+
5+
TkClassWizard allows users to deprecate different classes, class's parameters and types under a class's parameter.
6+
7+
All the deprecations can be made with the :func:`tkclasswiz.deprecation.register_deprecated` function.
8+
The function has 3 modes:
9+
10+
- Deprecate class globally (only ``cls`` parameter given)
11+
- Deprecate a class's parameter (``cls`` and ``parameter`` both given)
12+
- Deprecate a type under class's parameter (``cls``, ``parameter`` and ``types`` are all given).
13+
Please note that ``types`` is a variadic parameter, which means multiple types can be passed by
14+
just separating them with a comma.
15+
16+
17+
.. code-block:: python
18+
:caption: Deprecate usage of type :class:`~datetime.timedelta` under parameter ``next_service`` of class ``Car``.
19+
20+
from datetime import timedelta, datetime
21+
import tkclasswiz as wiz
22+
23+
class Car:
24+
def __init__(self, name: str, next_service: timedelta | datetime):
25+
... # Implementation
26+
27+
wiz.register_deprecated(Car, "next_service", timedelta)
28+
... # Other needed code
29+
30+
31+
The above example will create the following definition window:
32+
33+
.. image:: ./images/new_define_frame_struct_deprecation.png
34+
20.3 KB
Loading
24.3 KB
Loading
38.2 KB
Loading

docs/source/guide/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ Index:
1818
customrepr
1919
aliasing
2020
generics
21+
deprecations

docs/source/scripts/generate_autodoc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
if manual:
9999
_async_ = ":async:" if inspect.iscoroutinefunction(item) else ""
100100
annotations = get_type_hints(item)
101-
return_ano = annotations.pop("return")
101+
return_ano = annotations.pop("return", None)
102102
doc_str = inspect.cleandoc(item.__doc__)
103103
# Replace titles with list titles
104104
doc_str_titles = re.findall(r"[A-z]+\n-+", doc_str)

requirements/docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ sphinx-copybutton~=0.5.2
44
furo==2023.9.10
55
enum-tools[sphinx]~=0.11.0
66
sphinx-design[furo]~=0.5.0
7-
readthedocs-sphinx-search~=0.3.1
7+
readthedocs-sphinx-search~=0.3.2
88
sphinxcontrib-svg2pdfconverter~=1.2.2

tkclasswiz/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2727
SOFTWARE.
2828
"""
29-
__version__ = "1.3.1"
29+
30+
__version__ = "1.4.0"
31+
3032

3133
from .object_frame import *
3234
from .annotations import *
@@ -37,3 +39,4 @@
3739
from .storage import *
3840
from .utilities import *
3941
from .aliasing import *
42+
from .deprecation import *

0 commit comments

Comments
 (0)