Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 0067a95

Browse files
Closes #4 & minor documentation changes (see CHANGELOG.md)
1 parent 1a3c34f commit 0067a95

File tree

9 files changed

+78
-4
lines changed

9 files changed

+78
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Python-Multibar 4.0.1 (06.10.2022)
2+
3+
## Features
4+
- Add `multibar.INPUT_VALUES_CONTRACT` (alias to `multibar.WRITE_PROGRESS_CONTRACT`)
5+
6+
## Documentation changes
7+
- Add `Raises` section to `multibar.ProgressbarClient.get_progress()`
8+
- Add `Showcase` page with quick examples to github.io site

docs-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Markdown
66
mkdocstrings
77
mkdocstrings-python
88
mkdocs-autorefs
9+
termynal

docs/index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ Topic: Utilities
2828
!!! nav-menu "Navigation menu"
2929
[**FAQ**](faq.md){ .md-button }
3030
[**Quickstart**](quickstart.md){ .md-button }
31+
[**Showcase**](showcase.md){ .md-button }
3132
[**Python-Multibar**](about.md){ .md-button }
32-
[**Go to documentation**](errors.md){ .md-button }
33+
[**Docs**](errors.md){ .md-button }
3334

3435
<h1 align="center">Python-Multibar Minimap</h1>
3536

@@ -77,6 +78,8 @@ Topic: Utilities
7778
<br/>
7879
<a href="https://mkdocstrings.github.io/autorefs/">MkDocs auto-refs</a>
7980
<br/>
81+
<a href="https://github.com/daxartio/termynal">Mkdocs termynal</a>
82+
<br/>
8083
<a href="https://github.com/facelessuser">Isaac Muse</a>
8184
<br/>
8285
</p>

docs/showcase.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Base signature example
2+
3+
<!-- termynal -->
4+
5+
```
6+
$ import multibar
7+
$ writer = multibar.ProgressbarWriter()
8+
$ progressbar = writer.write(50, 100, length=6)
9+
+++---
10+
$ type(progressbar)
11+
[<class 'multibar.impl.progressbars.Progressbar'>](impl/progressbars.md)
12+
$ type(progressbar[0])
13+
[<class 'multibar.impl.sectors.Sector'>](impl/sectors.md)
14+
```
15+
16+
## Square Emoji signature example
17+
18+
<!-- termynal -->
19+
20+
```
21+
$ from multibar import ProgressbarWriter, SquareEmojiSignature
22+
$ writer = ProgressbarWriter.from_signature(SquareEmojiSignature())
23+
$ progressbar = writer.write(50, 100, length=6)
24+
🟧🟧🟧⬛️⬛️⬛️ # If the environment supports emoji
25+
```
26+
27+
## Square Emoji signature that supports `start` & `end` values
28+
29+
<!-- termynal -->
30+
31+
```
32+
$ from multibar import ProgressbarClient, SquareEmojiSignature, WRITER_HOOKS
33+
# Client configuration
34+
$ client = ProgressbarClient()
35+
$ client.writer.bind_signature(SquareEmojiSignature())
36+
$ client.set_hooks(WRITER_HOOKS)
37+
# Product
38+
$ progressbar = client.get_progress(100, 100, length=6)
39+
🔸🟧🟧🟧🟧🔸 # If the environment supports emoji
40+
```

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ nav:
5858
- About:
5959
- about.md
6060

61+
- Showcase:
62+
- showcase.md
63+
6164
- "Reference":
6265
- "api":
6366
- api/math_operations.md
@@ -88,6 +91,7 @@ nav:
8891
plugins:
8992
- search
9093
- autorefs
94+
- termynal
9195

9296
# Plugin for diagrams
9397
- mermaid2:

multibar/api/progressbars.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
from . import sectors
2828

29-
3029
SectorT = typing.TypeVar("SectorT", bound=sectors.AbstractSector)
3130
_NewValueType = typing.TypeVar("_NewValueType", bound=sectors.AbstractSector)
3231
_InstanceKind = typing.TypeVar("_InstanceKind", bound="ProgressbarAware[typing.Any]")

multibar/impl/clients.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,21 @@ def get_progress(
110110
length : int = 20, *
111111
Length of progressbar for progressbar math operations.
112112
113+
Raises
114+
------
115+
errors.TerminatedContractError
116+
This contract is signed by default. Checks if the Start value is greater
117+
than the End value, if so, an error will be raised.
118+
119+
!!! info
120+
You can unsubscribe from this contract as follows:
121+
```py hl_lines="4"
122+
import multibar
123+
124+
client = multibar.ProgressbarClient()
125+
client.contract_manager.terminate(multibar.INPUT_VALUES_CONTRACT)
126+
```
127+
113128
Returns
114129
-------
115130
progressbars.ProgressbarAware[sectors.AbstractSector]

multibar/impl/contracts.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"ContractManager",
2121
"WriteProgressContract",
2222
"WRITE_PROGRESS_CONTRACT",
23+
"INPUT_VALUES_CONTRACT",
2324
)
2425

2526
import typing
@@ -219,7 +220,7 @@ def check(self, *args: typing.Any, **kwargs: typing.Any) -> contracts.ContractCh
219220
start, end, length = meta["start_value"], meta["end_value"], meta["length"]
220221
if start > end:
221222
return contracts.ContractCheck.terminated(
222-
errors=["Start value cannot be more than end value."],
223+
errors=["`Start` value cannot be more than `End` value."],
223224
metadata=call_metadata,
224225
)
225226

@@ -320,3 +321,6 @@ def render_terminated_contract(
320321
For subscribing or unsubscribing of `WriteProgressContract` its recommended
321322
to use this variable, because this methods depends on object `id`.
322323
"""
324+
325+
INPUT_VALUES_CONTRACT = WRITE_PROGRESS_CONTRACT
326+
"""Alias to WRITE_PROGRESS_CONTRACT."""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ src_paths = ["multibar", "tests", "examples"]
3030

3131
[tool.poetry]
3232
name = "python-multibar"
33-
version = "4.0.0"
33+
version = "4.0.1"
3434
description = "Flexible wrapper for static progressbar writing."
3535
authors = ["DenyS <[email protected]>"]
3636
readme = "PYPI_README.md"

0 commit comments

Comments
 (0)