diff --git a/template/filters.py b/template/filters.py index 018c9ac0422ab8a6a5ebf2e5949a4ce689a088ee..993435afa6ee1a96ef97e15a8d1e3c2b9d1a5f90 100644 --- a/template/filters.py +++ b/template/filters.py @@ -2,6 +2,19 @@ def to_yaml(value): + ''' + Converts given data structure to YAML form. + Examples: + + >>> to_yaml([1,2,3]) + '[1, 2, 3]\\n' + >>> to_yaml({'a': 1, 'b': 2}) + '{a: 1, b: 2}\\n' + >>> to_yaml({1: {'a': [1,2,3]}}) + '1:\\n a: [1, 2, 3]\\n' + >>> to_yaml("abc") + 'abc\\n...\\n' + ''' from yaml import safe_dump return safe_dump(value) diff --git a/tox.ini b/tox.ini index 1ac57a887f6c612dbaf002ad645ccde42423948f..c1b9865a58b02fbac3790291c3eca13be6b87662 100644 --- a/tox.ini +++ b/tox.ini @@ -21,6 +21,7 @@ commands = check-manifest --ignore tox.ini,tests* python setup.py check -m -r -s flake8 . + python -m doctest template/filters.py template/__init__.py ./tests.sh [testenv:release]