From 2a051ffd70be90a4e64a4f583dc8d55c9294d0e6 Mon Sep 17 00:00:00 2001 From: Roman Mogylatov Date: Thu, 16 Aug 2018 23:52:56 +0300 Subject: [PATCH] Add factory patterns to docs --- docs/examples/chained_factories.rst | 22 ++++++++++++++++++++++ docs/examples/factory_of_factories.rst | 22 ++++++++++++++++++++++ docs/examples/index.rst | 2 ++ 3 files changed, 46 insertions(+) create mode 100644 docs/examples/chained_factories.rst create mode 100644 docs/examples/factory_of_factories.rst diff --git a/docs/examples/chained_factories.rst b/docs/examples/chained_factories.rst new file mode 100644 index 00000000..9233af7c --- /dev/null +++ b/docs/examples/chained_factories.rst @@ -0,0 +1,22 @@ +Chained Factories pattern +========================= + +This example demonstrate implementation of "Chained Factories" pattern. +Main idea of this pattern is about wrapping `Factory` into other `Factory` +that mix additional arguments or keyword arguments to a wrapped one. + +Listing of ``data.py``, demonstrates sample classes structure: + +.. literalinclude:: ../../examples/miniapps/factory_patterns/data.py + :language: python + :linenos: + +Listing of ``chained_factories.py``, demonstrates "Chained Factories" +pattern and provide some explanation: + +.. literalinclude:: ../../examples/miniapps/factory_patterns/chained_factories.py + :language: python + :linenos: + + +.. disqus:: diff --git a/docs/examples/factory_of_factories.rst b/docs/examples/factory_of_factories.rst new file mode 100644 index 00000000..adabd042 --- /dev/null +++ b/docs/examples/factory_of_factories.rst @@ -0,0 +1,22 @@ +Factory of Factories pattern +============================ + +This example demonstrate implementation of "Factory of Factories" pattern. +Main idea of this pattern is about creation of a :py:class:`Factory` that +creates another :py:class:`Factory` and mix additional arguments to it. + +Listing of ``data.py``, demonstrates sample classes structure: + +.. literalinclude:: ../../examples/miniapps/factory_patterns/data.py + :language: python + :linenos: + +Listing of ``factory_of_factories.py``, demonstrates "Chained Factories" +pattern and provide some explanation: + +.. literalinclude:: ../../examples/miniapps/factory_patterns/factory_of_factories.py + :language: python + :linenos: + + +.. disqus:: diff --git a/docs/examples/index.rst b/docs/examples/index.rst index 977a35a2..c61c4009 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -21,3 +21,5 @@ and powered by *Dependency Injector* framework. bundles_miniapp use_cases_miniapp password_hashing_miniapp + chained_factories + factory_of_factories