Skip to content

Commit d4fd305

Browse files
committed
Further docs improvements
1 parent d24742d commit d4fd305

1 file changed

Lines changed: 27 additions & 22 deletions

File tree

lib/membrane/testing/pipeline.ex

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,33 @@ defmodule Membrane.Testing.Pipeline do
1414
pass that options list to the `Membrane.Testing.Pipeline.start_link_supervised!/1`.
1515
The testing pipeline can be started in one of two modes - either with its `:default` behaviour, or by
1616
injecting a custom module behaviour. The usage of a `:default` pipeline implementation is presented below:
17+
```
18+
spec = [
19+
child(:el1, MembraneElement1)
20+
|> child(:el2, MembraneElement2)
21+
...
22+
]
1723
18-
spec = [
19-
child(:el1, MembraneElement1)
20-
|> child(:el2, MembraneElement2)
21-
...
22-
]
23-
options = [
24-
module: :default # :default is the default value for this parameter, so you do not need to pass it here
25-
spec: spec
26-
]
27-
pipeline = Membrane.Testing.Pipeline.start_link_supervised!(options)
24+
options = [
25+
module: :default # :default is the default value for this parameter, so you do not need to pass it here
26+
spec: spec
27+
]
2828
29+
pipeline = Membrane.Testing.Pipeline.start_link_supervised!(options)
30+
```
2931
You can also pass your custom pipeline's module as a `:module` option of
3032
the options list. Every callback of the module
3133
will be executed before the callbacks of Testing.Pipeline.
3234
Passed module has to return a proper spec. There should be no children
3335
nor links specified in options passed to test pipeline as that would
3436
result in a failure.
37+
```
38+
options = [
39+
module: Your.Module
40+
]
3541
36-
options = [
37-
module: Your.Module
38-
]
39-
pipeline = Membrane.Testing.Pipeline.start_link_supervised!(options)
40-
42+
pipeline = Membrane.Testing.Pipeline.start_link_supervised!(options)
43+
```
4144
See `t:Membrane.Testing.Pipeline.options/0` for available options.
4245
4346
## Assertions
@@ -53,15 +56,17 @@ defmodule Membrane.Testing.Pipeline do
5356
## Example usage
5457
5558
Firstly, we can start the pipeline providing its options as a keyword list:
59+
```
60+
import Membrane.ChildrenSpec
5661
57-
import Membrane.ChildrenSpec
58-
spec = [
59-
child(:source, Membrane.Testing.Source)
60-
|> child(:tested_element, TestedElement)
61-
|> child(:sink, Membrane.Testing.Sink)
62-
]
63-
{:ok, pipeline} = Membrane.Testing.Pipeline.start_link(spec: spec)
62+
spec = [
63+
child(:source, Membrane.Testing.Source)
64+
|> child(:tested_element, TestedElement)
65+
|> child(:sink, Membrane.Testing.Sink)
66+
]
6467
68+
{:ok, pipeline} = Membrane.Testing.Pipeline.start_link(spec: spec)
69+
```
6570
We can now wait till the end of the stream reaches the sink element (don't forget
6671
to import `Membrane.Testing.Assertions`):
6772

0 commit comments

Comments
 (0)