Browse Source

readme: added yaml export sample

Fabian Peter Hammerle 4 years ago
parent
commit
d97deb8759
2 changed files with 30 additions and 2 deletions
  1. 1 0
      .githooks/pre-commit
  2. 29 2
      README.md

+ 1 - 0
.githooks/pre-commit

@@ -14,3 +14,4 @@ pipenv sync --dev
 pipenv run black --check
 pipenv run pylint yamily tests/*
 pipenv run pytest --cov=yamily --cov-report=term-missing --cov-fail-under=100
+pipenv run python -m doctest README.md

+ 29 - 2
README.md

@@ -2,14 +2,41 @@
 
 Define family trees in YAML
 
-## setup
+## Setup
 
 ```sh
 $ sudo apt-get install python3-yaml # optional on debian
 $ pip3 install --user --upgrade yamily
 ```
 
-## develop
+## Usage
+
+### Export YAML
+
+```python
+>>> import datetime, yaml, yamily, yamily.yaml
+>>> alice = yamily.Person("alice")
+>>> alice.name = "Alice Test"
+>>> alice.birth_date = datetime.date(2019, 12, 23)
+>>> alice
+Person(alice, Alice Test, *2019-12-23)
+
+>>> alice.father = yamily.Person("alice-father")
+>>> alice.father.name = "Bob Test"
+
+>>> print(yaml.dump(alice, Dumper=yamily.yaml.Dumper))
+!person
+birth_date: 2019-12-23
+father: !person
+  identifier: alice-father
+  name: Bob Test
+identifier: alice
+name: Alice Test
+<BLANKLINE>
+
+```
+
+## Develop
 
 ```sh
 $ git clone git@git.hammerle.me:fphammerle/yamily.git