From cbe70692277f0ce487299f43539bf3ff1f644f77 Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Mon, 3 Aug 2015 15:49:55 +0300 Subject: [PATCH] Replacing callable provider documentation examples with literalincludes --- docs/providers/callable.rst | 42 ++++--------------------------------- 1 file changed, 4 insertions(+), 38 deletions(-) diff --git a/docs/providers/callable.rst b/docs/providers/callable.rst index 3fdc7c63..625399e9 100644 --- a/docs/providers/callable.rst +++ b/docs/providers/callable.rst @@ -19,26 +19,8 @@ Example: :width: 100% :align: center -.. code-block:: python - - """`Callable` providers example.""" - - from passlib.hash import sha256_crypt - - from objects.providers import Callable - from objects.injections import KwArg - - - # Password hasher and verifier providers (hash function could be changed - # anytime (for example, to sha512) without any changes in client's code): - password_hasher = Callable(sha256_crypt.encrypt, - KwArg('salt_size', 16), - KwArg('rounds', 10000)) - password_verifier = Callable(sha256_crypt.verify) - - # Making some asserts (client's code): - hashed_password = password_hasher('super secret') - assert password_verifier('super secret', hashed_password) +.. literalinclude:: ../../examples/providers/callable_injections.py + :language: python Callable providers delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -53,21 +35,5 @@ delegation* section for example. Example: -.. code-block:: python - - """`Callable` providers delegation example.""" - - import sys - - from objects.providers import Callable - from objects.providers import Delegate - - - # Some callable provider and few delegates of it: - callable_provider = Callable(sys.exit) - callable_provider_delegate1 = callable_provider.delegate() - callable_provider_delegate2 = Delegate(callable_provider) - - # Making some asserts: - assert callable_provider_delegate1() is callable_provider - assert callable_provider_delegate2() is callable_provider +.. literalinclude:: ../../examples/providers/callable_delegation.py + :language: python