Skip to content

Commit 5158350

Browse files
committed
feat!: release version 1.0.0
BREAKING CHANGE: Introduced changes that break backward compatibility.
1 parent 9d8f121 commit 5158350

29 files changed

Lines changed: 227 additions & 352 deletions

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ jobs:
2222

2323
- name: Action | Semantic Version Release
2424
id: release
25-
uses: python-semantic-release/python-semantic-release@v9.21.0
25+
uses: python-semantic-release/python-semantic-release@v10.0.2
2626
with:
2727
github_token: ${{ secrets.GITHUB_TOKEN }}
2828
git_committer_name: "github-actions"
2929
git_committer_email: "actions@users.noreply.github.com"
3030

3131
- name: Publish | Upload to GitHub Release Assets
32-
uses: python-semantic-release/publish-action@v9.21.0
32+
uses: python-semantic-release/publish-action@v10.0.2
3333
if: steps.release.outputs.released == 'true'
3434
with:
3535
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ jobs:
3737

3838
- name: Run pytest
3939
run: |
40-
uv pip install .
4140
uv run pytest

CHANGELOG.md

Lines changed: 0 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -1,174 +0,0 @@
1-
# CHANGELOG
2-
3-
4-
## v0.6.1 (2025-05-08)
5-
6-
### Bug Fixes
7-
8-
- **content**: Remove debug print statement and ensure proper handling of empty parts in rendering
9-
([`0393f2a`](https://github.com/m-xim/textcompose/commit/0393f2aa19342f82ce7c88e465dbde3272c5a175))
10-
11-
12-
## v0.6.0 (2025-05-08)
13-
14-
### Features
15-
16-
- **template**: Add separator option to Template for customizable rendering
17-
([`a25b9b5`](https://github.com/m-xim/textcompose/commit/a25b9b55d22e9bdcc8ae5a2b2bebd950734baa0d))
18-
19-
20-
## v0.5.0 (2025-05-08)
21-
22-
### Features
23-
24-
- **logical**: Add If class for conditional rendering logic
25-
([`459e0e1`](https://github.com/m-xim/textcompose/commit/459e0e104cc2a3cb7436765d6b3f70795584d931))
26-
27-
28-
## v0.4.0 (2025-05-04)
29-
30-
### Documentation
31-
32-
- Update README to enhance section headings with emojis
33-
([`2b48887`](https://github.com/m-xim/textcompose/commit/2b48887aa1bb59cc5969cc53ba6ccdedf3bc693e))
34-
35-
### Features
36-
37-
- **content**: Update Value type to support callable for dynamic value resolution
38-
([`2c90531`](https://github.com/m-xim/textcompose/commit/2c9053145eaa2b53ca044406bdae998a909e582d))
39-
40-
41-
## v0.3.0 (2025-05-03)
42-
43-
### Bug Fixes
44-
45-
- **content**: Resolve circular import by moving resolve_value to BaseContent
46-
([`a320b19`](https://github.com/m-xim/textcompose/commit/a320b19cc4115cce406e900bee67f7e0e87147ce))
47-
48-
### Features
49-
50-
- Add resolve_value and extend support for dynamic types in group, and template
51-
([`e5bfaeb`](https://github.com/m-xim/textcompose/commit/e5bfaeb7ebb470483719eaef9354c8b08a7eac6a))
52-
53-
54-
## v0.2.0 (2025-05-02)
55-
56-
### Chores
57-
58-
- **release**: Fix
59-
([`365ad02`](https://github.com/m-xim/textcompose/commit/365ad025db2b580e16941d207491a18560034573))
60-
61-
- **release**: Migrate to single-branch workflow and manual release process
62-
([`add9991`](https://github.com/m-xim/textcompose/commit/add9991277ceaa84afc324cace9d894b50a308c2))
63-
64-
### Features
65-
66-
- Custom arg in render
67-
([`94fc405`](https://github.com/m-xim/textcompose/commit/94fc405c44f3aafa34a55dabf7d56374ee1ab45f))
68-
69-
70-
## v0.1.4 (2025-05-02)
71-
72-
73-
## v0.1.4-rc.1 (2025-05-02)
74-
75-
### Chores
76-
77-
- **readme**: Fix pypi badge
78-
([`bd30d8d`](https://github.com/m-xim/textcompose/commit/bd30d8dee487d5f717cae2275a3687488dfb58b4))
79-
80-
81-
## v0.1.3 (2025-05-02)
82-
83-
### Chores
84-
85-
- **release**: Add project metadata
86-
([`727d910`](https://github.com/m-xim/textcompose/commit/727d9109f66f129cccd4a1263036dc8888b376b7))
87-
88-
### Continuous Integration
89-
90-
- Set committer
91-
([`d2e1cff`](https://github.com/m-xim/textcompose/commit/d2e1cff651e9fc13a12c6e6cd95584426d4df645))
92-
93-
94-
## v0.1.3-rc.2 (2025-05-02)
95-
96-
### Bug Fixes
97-
98-
- **Container**: `*children`, `when` is name arg
99-
([`5d726e5`](https://github.com/m-xim/textcompose/commit/5d726e548691162f38737c4d31903725c63b05d1))
100-
101-
### Continuous Integration
102-
103-
- Cleaning
104-
([`17fb568`](https://github.com/m-xim/textcompose/commit/17fb5687113d3f0c3694e963ae153409bc7d4279))
105-
106-
- Fix pip
107-
([`71c2d0f`](https://github.com/m-xim/textcompose/commit/71c2d0ffef0e8c85da1c9b89fb6c84568dd81624))
108-
109-
- Fix pytest
110-
([`429e0ba`](https://github.com/m-xim/textcompose/commit/429e0ba95c17bc858ab47db9901a75df24ee4b04))
111-
112-
- Fix uv sync
113-
([`6152b99`](https://github.com/m-xim/textcompose/commit/6152b99f0155d902096af632a216aed8be8d7d7d))
114-
115-
### Testing
116-
117-
- Add tests
118-
([`fa30176`](https://github.com/m-xim/textcompose/commit/fa301760d5734d249c5c7c59a7f9f954de6bf0c4))
119-
120-
121-
## v0.1.3-rc.1 (2025-05-01)
122-
123-
### Bug Fixes
124-
125-
- **Text**: Condition
126-
([`1d9dca2`](https://github.com/m-xim/textcompose/commit/1d9dca26f2c2f6c41416c9009a29e3c002feef50))
127-
128-
### Continuous Integration
129-
130-
- Rename
131-
([`a3737ed`](https://github.com/m-xim/textcompose/commit/a3737ed9b72de9d9d245bb2398616f9b0822254b))
132-
133-
### Documentation
134-
135-
- Add README
136-
([`0ef408e`](https://github.com/m-xim/textcompose/commit/0ef408e808bbde043c5ef12c3928e006b0631183))
137-
138-
139-
## v0.1.2 (2025-05-01)
140-
141-
### Bug Fixes
142-
143-
- Bump version for re-upload
144-
([`10e3415`](https://github.com/m-xim/textcompose/commit/10e34150ca94eec75af46fe3bbda121a4b97b802))
145-
146-
147-
## v0.1.1 (2025-05-01)
148-
149-
### Bug Fixes
150-
151-
- Lock
152-
([`1811f28`](https://github.com/m-xim/textcompose/commit/1811f28b954106735e1e28d513378a426fb11c15))
153-
154-
- Lock
155-
([`6d4b44c`](https://github.com/m-xim/textcompose/commit/6d4b44c8719a45f52834391777d5b98af452a36f))
156-
157-
- Lock
158-
([`fbdcd6c`](https://github.com/m-xim/textcompose/commit/fbdcd6caf211c7a6a33ac6acc4a08a2e8bcdeb8f))
159-
160-
- Release.yml
161-
([`6a51a9d`](https://github.com/m-xim/textcompose/commit/6a51a9d68cf05e38576de6c29b3244a33fe21a9d))
162-
163-
164-
## v0.1.0 (2025-05-01)
165-
166-
### Bug Fixes
167-
168-
- Release.yml
169-
([`67e6c54`](https://github.com/m-xim/textcompose/commit/67e6c54ca966465eae6614b3f8af2bdd62f4c877))
170-
171-
### Features
172-
173-
- Init project
174-
([`da750ca`](https://github.com/m-xim/textcompose/commit/da750ca2c3470d1a4a337af533f68221f3cf4807))

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- Formatting via f-string and Jinja2
1919
- Easily extensible with new components
2020

21-
---
21+
2222

2323
## 🚀 Installation
2424

@@ -35,50 +35,47 @@ uv add textcompose
3535
pip install textcompose
3636
```
3737

38-
---
39-
4038

4139
## 💻 Usage
4240

4341
### Components Overview
4442

4543
#### General
4644

47-
- `Template` — combines and renders components as a structured text block.
48-
49-
#### Content Blocks
45+
- `Template` — main class for combining and rendering components
5046

51-
- `BaseContent` — abstract base class for all content components
5247

48+
#### Elements
49+
`Element` — abstract base class for all element components
5350

5451
- `Text` — outputs static text
5552
- `Format` — dynamic formatting via f-string
5653
- `Jinja` — rendering via Jinja2 templates
5754

5855
#### Containers
56+
`Container` — abstract base class for all container components
5957

60-
- `BaseContainer` — abstract base class for containers
61-
62-
63-
- `Group` — groups children with a separator
58+
- `Group` — groups child components with a separator
6459
- `List` — repeats a template for a collection
6560

6661
#### Logic Components
62+
`Logic` — abstract base class for all container components
6763

6864
- `If` — conditional rendering (`if_`, `then_`, `else_`)
6965

70-
All components support the `when` parameter for conditional rendering.
71-
7266
---
67+
All components support the `when` parameter — it controls the display of the component and accepts a condition (expression, function or magic_filter).
7368

7469
## 📝 Example
7570

71+
All usage examples can be found in the [`example`](./example) folder.
72+
7673
```python
7774
from magic_filter import F
7875

7976
from textcompose import Template
8077
from textcompose.container import Group, List
81-
from textcompose.content import Format, Text, Jinja
78+
from textcompose.elements import Format, Jinja, Text
8279
from textcompose.logic import If
8380

8481
template = Template(
@@ -136,4 +133,4 @@ Thank you for using our service!
136133

137134
## 👨‍💻 Contributing
138135

139-
We welcome contributions to `TextCompose`. If you have suggestions or improvements, please open an issue or submit a pull request.
136+
Contributions are welcome! If you have suggestions or improvements, please open an issue or submit a pull request.

example/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from textcompose import Template
44
from textcompose.container import Group, List
5-
from textcompose.content import Format, Text, Jinja
5+
from textcompose.elements import Format, Jinja, Text
66
from textcompose.logic import If
77

88
template = Template(
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
from typing import Dict, Any, Optional
2-
from textcompose.content.content import BaseContent, Condition, Value
1+
from typing import Any, Optional, Mapping
32

3+
from textcompose.core import resolve_value, Condition, Value
4+
from textcompose.elements.base import Element
45

5-
class I18nTC(BaseContent):
6+
7+
class I18nTC(Element):
68
def __init__(
79
self,
810
text: str,
@@ -16,14 +18,14 @@ def __init__(
1618
self.locale = locale
1719
self.mapping = mapping
1820

19-
def _resolve_mapping(self, context: Dict[str, Any]) -> Dict[str, Any]:
21+
def _resolve_mapping(self, context: Mapping[str, Any]) -> Mapping[str, Any]:
2022
resolved = {}
2123
for key, val in self.mapping.items():
22-
result = self.resolve_value(val, context)
24+
result = resolve_value(val, context)
2325
resolved[key] = result if result is not None else ""
2426
return resolved
2527

26-
def render(self, context: Dict[str, Any], **kwargs) -> Optional[str]:
28+
def render(self, context, **kwargs) -> Optional[str]:
2729
if not self._check_when(context, **kwargs):
2830
return None
2931

@@ -32,6 +34,6 @@ def render(self, context: Dict[str, Any], **kwargs) -> Optional[str]:
3234
raise ValueError("Missing 'i18n' in render kwargs")
3335

3436
params = self._resolve_mapping(context)
35-
locale = self.resolve_value(self.locale, context) if self.locale else None
37+
locale = resolve_value(self.locale, context) if self.locale else None
3638

3739
return i18n.get(self.text, locale, **params)

tests/test_format.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
import pytest
2-
from textcompose.content.format import Format
32

3+
from textcompose.elements.format import Format
44

5-
def test_format_basic_render():
6-
format_content = Format("Hello, {name}!")
7-
result = format_content.render({"name": "Alice"})
8-
assert result == "Hello, Alice!"
95

10-
11-
def test_format_missing_key():
12-
format_content = Format("Hello, {name}!")
13-
with pytest.raises(KeyError):
14-
format_content.render({})
15-
16-
17-
def test_format_with_condition():
18-
format_content = Format("Conditional", when=lambda context: context.get("render", False))
19-
result = format_content.render({"render": True})
20-
assert result == "Conditional"
21-
22-
result = format_content.render({"render": False})
23-
assert result is None
6+
@pytest.mark.parametrize(
7+
"template,context,when,expected",
8+
[
9+
("Hello {name}", {"name": "Alice"}, None, "Hello Alice"),
10+
("{x} + {y}", {"x": 1, "y": 2}, True, "1 + 2"),
11+
("{x}", {"x": "skip"}, False, None),
12+
],
13+
)
14+
def test_format(template, context, when, expected):
15+
assert Format(template, when=when).render(context) == expected

tests/test_group.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
from textcompose.container.group import Group
2-
from textcompose.content.text import Text
3-
4-
5-
def test_group_render_with_separator():
6-
text1 = Text("One")
7-
text2 = Text("Two")
8-
group = Group(text1, text2, sep=", ")
9-
10-
result = group.render({})
11-
assert result == "One, Two"
1+
import pytest
122

3+
from textcompose.container.group import Group
134

14-
def test_group_render_with_conditions():
15-
text1 = Text("Visible", when=True)
16-
text2 = Text("Hidden", when=False)
17-
group = Group(text1, text2)
185

19-
result = group.render({})
20-
assert result == "Visible"
6+
@pytest.mark.parametrize(
7+
"children,sep,when,context,expected",
8+
[
9+
(["a", "b", "c"], ",", None, {}, "a,b,c"),
10+
(["x", None, "y"], "-", True, {}, "x-y"),
11+
(["1", "2"], "|", False, {}, None),
12+
],
13+
)
14+
def test_group(children, sep, when, context, expected):
15+
group = Group(*children, sep=sep, when=when)
16+
assert group.render(context) == expected

tests/test_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
from textcompose.elements.text import Text
12
from textcompose.template import Template
2-
from textcompose.content.text import Text
33

44

55
def test_template_render_multiple_components():

0 commit comments

Comments
 (0)