Improved readme and serialization docs.

This commit is contained in:
Felix Krause 2016-02-16 11:05:36 +01:00
parent 9be97ff386
commit 151d795f07
2 changed files with 54 additions and 1 deletions

View File

@ -21,6 +21,22 @@ available features.
they are an implementation detail and should not be visible to the caller.
same goes for `lazyLoadTag` and `safeLoadUri`.
## Developers
```bash
nim tests # runs all tests
nim parserTests # runs parser tests
nim serializationTests # runs serialization tests
nim documentation # builds documentation to folder docout
nim server # builds the REST server used for the testing ground
nim bench # runs benchmarks, requires libyaml
nim clean # guess
nim build # build a library
```
Project is tested against current develop branch of Nim. Older Nim versions
probably do not work.
## License
[MIT](copying.txt)

View File

@ -18,6 +18,7 @@ languages like Ruby, Nim cannot load a YAML character stream without knowing the
resulting type beforehand. For example, if you want to load this piece of YAML:
.. code-block:: yaml
%YAML 1.2
--- !nim:system:seq(nim:system:int8)
- 1
@ -72,6 +73,7 @@ types in them cannot be loaded to Nim collection types. For example, this
sequence:
.. code-block:: yaml
%YAML 1.2
--- !!seq
- !!int 1
@ -136,4 +138,39 @@ be applied to scalar and collection types implemented by NimYAML, but you can
for example use it on a certain ``seq`` type:
.. code-block:: nim
setTagUriForType(seq[string], "!nim:my:seq")
Customize Serialization
=======================
It is possible to customize the serialization of a type. For this, you need to
implement two procs, ``constructObject̀`` and ``representObject``. If you only
need to process the type in one direction (loading or dumping), you can omit
the other proc.
constructObject
---------------
.. code-block:: nim
proc constructObject*(s: var YamlStream, c: ConstructionContext,
result: var MyObject)
{.raises: [YamlConstructionError, YamlStreamError.}
This proc should construct the type from a ``YamlStream``.
**TBD: More documentation here**
representObject
---------------
.. code-block:: nim
proc representObject*(value: MyObject, ts: TagStyle = tsNone,
c: SerializationContext): RawYamlStream {.raises: [].}
This proc should return an iterator over ``YamlStreamEvent`` which represents
the type.
**TBD: More documentation here**