Skip to content

Commit 75dd793

Browse files
committed
docs: Don't show boilerplate code in the use guide
We filter out all the boilerplate (importing, declaring some variables) from the code shown in the user guide, as it is distracting for such a high-level introduction. This means more examples listed in modules have the boilerplate removed from the generated docs. Examples in classes or functions, that usually show up in the API docs are kept as before, with all the code. This is so users wanting to dive deeper into the library can still copy&paste code snippets from these examples and expect them to mostly work. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 809b541 commit 75dd793

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

src/frequenz/channels/_exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
was closed while seding or receiving a message, the original exception will be
2020
available as the cause of the exception:
2121
22-
```python
22+
```python show_lines="6:"
2323
from frequenz.channels import Anycast, ChannelClosedError, SenderError
2424
2525
channel = Anycast[int](name="test-channel")
@@ -44,7 +44,7 @@
4444
explicitly calling [`receive()`][frequenz.channels.Receiver.receive] on the
4545
receiver after the iteration is done:
4646
47-
```python
47+
```python show_lines="6:"
4848
from frequenz.channels import Anycast, ChannelClosedError, ReceiverStoppedError
4949
5050
channel = Anycast[int](name="test-channel")

src/frequenz/channels/_merge.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
stream, you can use [`merge()`][frequenz.channels.merge] to create a new receiver that
1010
will receive messages from all the given receivers:
1111
12-
```python
12+
```python show_lines="8:"
1313
from frequenz.channels import Anycast, Receiver, merge
1414
1515
channel1: Anycast[int] = Anycast(name="channel1")

src/frequenz/channels/_receiver.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
iterators][typing.AsyncIterator], so the easiest way to receive values from them as
1212
a stream is to use `async for`:
1313
14-
```python
14+
```python show_lines="6:"
1515
from frequenz.channels import Anycast
1616
1717
channel = Anycast[int](name="test-channel")
@@ -24,7 +24,7 @@
2424
If you need to receive values in different places or expecting a particular
2525
sequence, you can use the [`receive()`][frequenz.channels.Receiver.receive] method:
2626
27-
```python
27+
```python show_lines="6:"
2828
from frequenz.channels import Anycast
2929
3030
channel = Anycast[int](name="test-channel")
@@ -42,7 +42,7 @@
4242
If you need to transform the received values, receivers provide a
4343
[`map()`][frequenz.channels.Receiver.map] method to easily do so:
4444
45-
```python
45+
```python show_lines="6:"
4646
from frequenz.channels import Anycast
4747
4848
channel = Anycast[int](name="test-channel")
@@ -71,7 +71,7 @@
7171
closed), a [`ReceiverStoppedError`][frequenz.channels.ReceiverStoppedError] exception
7272
is raised by [`receive()`][frequenz.channels.Receiver.receive] method.
7373
74-
```python
74+
```python show_lines="6:"
7575
from frequenz.channels import Anycast
7676
7777
channel = Anycast[int](name="test-channel")
@@ -88,7 +88,7 @@
8888
When used as an async iterator, the iteration will just stop without raising an
8989
exception:
9090
91-
```python
91+
```python show_lines="6:"
9292
from frequenz.channels import Anycast
9393
9494
channel = Anycast[int](name="test-channel")

src/frequenz/channels/_select.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
function to check the source of the message, and the
1919
[`value`][frequenz.channels.Selected.value] attribute to access the message:
2020
21-
```python
21+
```python show_lines="8:"
2222
from frequenz.channels import Anycast, ReceiverStoppedError, select, selected_from
2323
2424
channel1: Anycast[int] = Anycast(name="channel1")
@@ -51,7 +51,7 @@
5151
If for some reason you want to ignore a received value, just add the receiver to
5252
the if-chain and do nothing with the value:
5353
54-
```python
54+
```python show_lines="8:"
5555
from frequenz.channels import Anycast, select, selected_from
5656
5757
channel1: Anycast[int] = Anycast(name="channel1")
@@ -76,7 +76,7 @@
7676
[`was_stopped()`][frequenz.channels.Selected.was_stopped] method to check if the
7777
selected [receiver][frequenz.channels.Receiver] was stopped:
7878
79-
```python
79+
```python show_lines="8:"
8080
from frequenz.channels import Anycast, select, selected_from
8181
8282
channel1: Anycast[int] = Anycast(name="channel1")
@@ -111,7 +111,7 @@
111111
112112
You can use a try-except block to handle exceptions as usual:
113113
114-
```python
114+
```python show_lines="8:"
115115
from frequenz.channels import Anycast, ReceiverStoppedError, select, selected_from
116116
117117
channel1: Anycast[int] = Anycast(name="channel1")

src/frequenz/channels/_sender.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
usually created by calling `channel.new_sender()`, and are a very simple abstraction
1111
that only provides a single [`send()`][frequenz.channels.Sender.send] method:
1212
13-
```python
13+
```python show_lines="6:"
1414
from frequenz.channels import Anycast
1515
1616
channel = Anycast[int](name="test-channel")
@@ -36,7 +36,7 @@
3636
If there is any failure sending a message,
3737
a [SenderError][frequenz.channels.SenderError] exception is raised.
3838
39-
```python
39+
```python show_lines="6:"
4040
from frequenz.channels import Anycast
4141
4242
channel = Anycast[int](name="test-channel")

0 commit comments

Comments
 (0)