Skip to content

Commit 2a051ff

Browse files
committed
Add factory patterns to docs
1 parent 50af250 commit 2a051ff

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Chained Factories pattern
2+
=========================
3+
4+
This example demonstrate implementation of "Chained Factories" pattern.
5+
Main idea of this pattern is about wrapping `Factory` into other `Factory`
6+
that mix additional arguments or keyword arguments to a wrapped one.
7+
8+
Listing of ``data.py``, demonstrates sample classes structure:
9+
10+
.. literalinclude:: ../../examples/miniapps/factory_patterns/data.py
11+
:language: python
12+
:linenos:
13+
14+
Listing of ``chained_factories.py``, demonstrates "Chained Factories"
15+
pattern and provide some explanation:
16+
17+
.. literalinclude:: ../../examples/miniapps/factory_patterns/chained_factories.py
18+
:language: python
19+
:linenos:
20+
21+
22+
.. disqus::
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Factory of Factories pattern
2+
============================
3+
4+
This example demonstrate implementation of "Factory of Factories" pattern.
5+
Main idea of this pattern is about creation of a :py:class:`Factory` that
6+
creates another :py:class:`Factory` and mix additional arguments to it.
7+
8+
Listing of ``data.py``, demonstrates sample classes structure:
9+
10+
.. literalinclude:: ../../examples/miniapps/factory_patterns/data.py
11+
:language: python
12+
:linenos:
13+
14+
Listing of ``factory_of_factories.py``, demonstrates "Chained Factories"
15+
pattern and provide some explanation:
16+
17+
.. literalinclude:: ../../examples/miniapps/factory_patterns/factory_of_factories.py
18+
:language: python
19+
:linenos:
20+
21+
22+
.. disqus::

docs/examples/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ and powered by *Dependency Injector* framework.
2121
bundles_miniapp
2222
use_cases_miniapp
2323
password_hashing_miniapp
24+
chained_factories
25+
factory_of_factories

0 commit comments

Comments
 (0)