Skip to content

Commit

Permalink
Second positional "type" argument of the Field and Option is now requ…
Browse files Browse the repository at this point in the history
…ired. Refactored "hiku.graph" module documentation.
  • Loading branch information
vmagamedov committed Sep 21, 2016
1 parent b75083f commit 3c151f4
Show file tree
Hide file tree
Showing 14 changed files with 236 additions and 165 deletions.
5 changes: 4 additions & 1 deletion docs/changelog/changes_02.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ Backward-incompatible changes
- Moved type :py:class:`hiku.typedef.types.Unknown` to the
:py:class:`hiku.types.Unknown`

- Positional ``type`` argument in :py:class:`hiku.graph.Field` and in
:py:class:`hiku.graph.Option` now is required

New features
~~~~~~~~~~~~

Expand Down Expand Up @@ -128,7 +131,7 @@ New features
return [ctx['storage'][f.name] for f in fields]
Root([
Field('foo', func),
Field('foo', None, func),
])
engine.execute(graph, read('[:foo]'),
Expand Down
9 changes: 9 additions & 0 deletions docs/guide/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ setup an environment:
Simplest one-field graph
~~~~~~~~~~~~~~~~~~~~~~~~

.. note:: Source code of this example can be found
`on GitHub <https://github.com/vmagamedov/hiku/blob/master/docs/guide/basics/test_stage1.py>`_.

Let's define graph with only one field, which is easy to compute, for example it
would be a current time:

Expand Down Expand Up @@ -54,6 +57,9 @@ the console.
Introducing edges and links
~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. note:: Source code of this example can be found
`on GitHub <https://github.com/vmagamedov/hiku/blob/master/docs/guide/basics/test_stage2.py>`_.

This is cool, but what if we want to return some application data? First of all
lets define our data:

Expand Down Expand Up @@ -105,6 +111,9 @@ Or in the program:
Linking edge to edge
~~~~~~~~~~~~~~~~~~~~

.. note:: Source code of this example can be found
`on GitHub <https://github.com/vmagamedov/hiku/blob/master/docs/guide/basics/test_stage3.py>`_.

Let's extend our data with one more entity - ``actor``:

.. literalinclude:: basics/test_stage3.py
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/basics/test_stage1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

GRAPH = Graph([
Root([
Field('now', lambda _: [datetime.now().isoformat()]),
Field('now', None, lambda _: [datetime.now().isoformat()]),
]),
])

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/basics/test_stage2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def to_characters_link():

GRAPH = Graph([
Edge('character', [
Field('name', character_data),
Field('species', character_data),
Field('name', None, character_data),
Field('species', None, character_data),
]),
Root([
Link('characters', Many, to_characters_link,
Expand Down
10 changes: 5 additions & 5 deletions docs/guide/basics/test_stage3.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ def to_characters_link():

GRAPH = Graph([
Edge('character', [
Field('id', character_data),
Field('name', character_data),
Field('species', character_data),
Field('id', None, character_data),
Field('name', None, character_data),
Field('species', None, character_data),
Link('actors', Many, character_to_actors_link,
edge='actor', requires='id'),
]),
Edge('actor', [
Field('id', actor_data),
Field('name', actor_data),
Field('id', None, actor_data),
Field('name', None, actor_data),
Link('character', One, actor_to_character_link,
edge='character', requires='id'),
]),
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/graph.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.. automodule:: hiku.graph
:members:
:members: Graph, Root, Edge, Field, Link, Maybe, One, Many, Nothing, Option
:special-members: __init__

0 comments on commit 3c151f4

Please sign in to comment.