Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Feb 17, 2024
1 parent 364bbca commit 58e4d55
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ build:
python: "3.11"

mkdocs:
configuration: docs/mkdocs.yml
configuration: mkdocs.yml

# Optionally declare the Python requirements required to build your docs
python:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/quick_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ while token:
print(counter)
```

In this code, we use a token that describes several restrictions: on the [number of iterations](/types_of_tokens/CounterToken/) of the cycle, on [time](/types_of_tokens/TimeoutToken/), as well as on the [occurrence](/types_of_tokens/ConditionToken/) of a random unlikely event. When any of the indicated events occur, the cycle stops.
In this code, we use a token that describes several restrictions: on the [number of iterations](/docs/types_of_tokens/CounterToken/) of the cycle, on [time](/docs/types_of_tokens/TimeoutToken/), as well as on the [occurrence](/docs/types_of_tokens/ConditionToken/) of a random unlikely event. When any of the indicated events occur, the cycle stops.

In fact, the library's capabilities are much broader, read the documentation below.
14 changes: 7 additions & 7 deletions docs/docs/what_are_tokens/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ token.check()

Each type of token has a corresponding type of exception that can be raised in this case:

- [`SimpleToken`](types_of_tokens/SimpleToken/) -> `CancellationError`
- [`ConditionToken`](/types_of_tokens/ConditionToken/) -> `ConditionCancellationError`
- [`TimeoutToken`](/types_of_tokens/TimeoutToken/) -> `TimeoutCancellationError`
- [`CounterToken`](/types_of_tokens/CounterToken/) -> `CounterCancellationError`
- [`SimpleToken`](/docs/types_of_tokens/SimpleToken/) -> `CancellationError`
- [`ConditionToken`](/docs/types_of_tokens/ConditionToken/) -> `ConditionCancellationError`
- [`TimeoutToken`](/docs/types_of_tokens/TimeoutToken/) -> `TimeoutCancellationError`
- [`CounterToken`](/docs/types_of_tokens/CounterToken/) -> `CounterCancellationError`

When you call the `check()` method on any token, one of two things will happen. If it (or any of the tokens nested in it) was canceled by calling the `cancel()` method, `CancellationError` will always be raised. But if the cancellation occurred as a result of the unique ability of the token, such as for `TimeoutToken` - timeout expiration, then an exception specific to this type of token will be raised.

You can import each of these exceptions from the library directly:
`ConditionCancellationError`, `TimeoutCancellationError` and `CounterCancellationError` are inherited from `CancellationError`, so if you're not sure which exception specifically you're catching, catch `CancellationError`. But also all the listed exceptions can always be imported separately:

```python
from cantok import CancellationError, ConditionCancellationError, TimeoutCancellationError, CounterCancellationError
```

Also each token class has its own exception and it can be found in the `exception` attribute of the class:
You can also choose not to import these exceptions at all. For each token class, the corresponding exception class is located in the `exception` attribute:

```python
from cantok import TimeoutToken, CancellationError
Expand All @@ -37,7 +37,7 @@ except CancellationError as e:
print(type(e) is TimeoutToken.exception) # True
```

Each exception object has a `token` attribute indicating the specific token that was canceled. This can be useful in situations where several tokens are nested in one another and you want to find out which one has been canceled:
And each exception object has a `token` attribute indicating the specific token that was canceled. This can be useful in situations where several tokens are nested in one another and you want to find out which one has been canceled:

```python
from cantok import SimpleToken, TimeoutToken, CancellationError
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/what_are_tokens/summation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Any tokens can be summed up among themselves. The summation operation generates another [`SimpleToken`](#simple-token) that includes the previous 2:
Any tokens can be summed up among themselves. The summation operation generates another [`SimpleToken`](/docs/types_of_tokens/SimpleToken/) that includes the previous 2:

```python
from cantok import SimpleToken, TimeoutToken
Expand Down
43 changes: 0 additions & 43 deletions docs/mkdocs.yml

This file was deleted.

43 changes: 43 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
site_name: 'CANTOK'
theme:
name: material
logo: assets/logo_6.png
favicon: assets/favicon.ico
features:
- content.code.copy
- navigation.instant
- navigation.tabs
- navigation.sections
- navigation.expand
- navigation.indexes
- search.highlight
- search.share
palette:
primary: black
accent: pink
repo_url: https://github.com/pomponchik/cantok
docs_dir: docs
nav:
- Installation: docs/installation.md
- Quick start: docs/quick_start.md
- The pattern: docs/the_pattern.md
- What are tokens:
- In general: docs/what_are_tokens/in_general.md
- Embedding one into another: docs/what_are_tokens/embedding.md
- Cancel and read the status: docs/what_are_tokens/cancel_and_read_the_status.md
- Exceptions: docs/what_are_tokens/exceptions.md
- Summation: docs/what_are_tokens/summation.md
- Waiting for cancellation: docs/what_are_tokens/waiting.md
- Types of tokens:
- SimpleToken: docs/types_of_tokens/SimpleToken.md
- ConditionToken: docs/types_of_tokens/ConditionToken.md
- TimeoutToken: docs/types_of_tokens/TimeoutToken.md
- CounterToken: docs/types_of_tokens/CounterToken.md
markdown_extensions:
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences

0 comments on commit 58e4d55

Please sign in to comment.