diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e4886..4c3afa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 2.1.0 (upcoming) +## 2.1.0 Features: @@ -39,6 +39,8 @@ Bugfixes: * Fixed a bug that prevented the presenter from outputting compact flow mappings in cMixed mode. * Fixed block scalars as mapping keys not being presented properly. + * Added workaround for a regression bug in Nim 2.0.2 + (https://github.com/nim-lang/Nim/issues/23112) ## 2.0.0 diff --git a/doc/api.txt b/doc/api.txt index 6c7d468..f05899a 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -3,10 +3,11 @@ API Overview ============ .. importdoc:: - api/yaml/loading.nim, api/yaml/dumping.nim, api/yaml/annotations.nim, - api/yaml/taglib.nim, api/yaml/style.nim, api/yaml/dom.nim, api/yaml/tojson.nim, + api/yaml/loading.nim, api/yaml/dumping.nim, api/yaml/native.nim, + api/yaml/annotations.nim, api/yaml/taglib.nim, api/yaml/style.nim, + api/yaml/dom.nim, api/yaml/tojson.nim, api/yaml/parser.nim, api/yaml/presenter.nim, api/yaml/data.nim, - api/yaml/stream.nim + api/yaml/stream.nim Introduction ============ diff --git a/doc/serialization.txt b/doc/serialization.txt index c33ec4f..25aad49 100644 --- a/doc/serialization.txt +++ b/doc/serialization.txt @@ -2,17 +2,22 @@ Serialization Overview ====================== +.. importdoc:: + api/yaml/loading.nim, api/yaml/dumping.nim, api/yaml/native.nim, + api/yaml/annotations.nim, api/yaml/taglib.nim, api/yaml/style.nim, + api/yaml/dom.nim, api/yaml/tojson.nim, + api/yaml/parser.nim, api/yaml/presenter.nim, api/yaml/data.nim, + api/yaml/stream.nim + Introduction ============ NimYAML tries hard to make transforming YAML characters streams to native Nim types and vice versa as easy as possible. In simple scenarios, you might not -need anything else than the two procs -`dump `_ -and `load `_. On the other side, the process -should be as customizable as possible to allow the user to tightly control how -the generated YAML character stream will look and how a YAML character stream is -interpreted. +need anything else than the two procs `dump`_ and `load`_. On the other side, +the process should be as customizable as possible to allow the user to tightly +control how the generated YAML character stream will look and how a YAML +character stream is interpreted. An important thing to remember in NimYAML is that unlike in interpreted languages like Ruby, Nim cannot load a YAML character stream without knowing the @@ -89,7 +94,7 @@ However, it doesn't need to. For example, if you have a YAML file like this: - 1 - 2 -You can simply load it into a `seq[int]`. If your YAML file contains differently +You can simply load it into a ``seq[int]``. If your YAML file contains differently typed values in the same collection, you can use an implicit variant object, see below. @@ -247,9 +252,8 @@ These tags are generated on the fly based on the types you instantiate ``Table`` or ``seq`` with. You may customize the tags used for your types by using the template -`setTagUri `_. It may not -be applied to scalar and collection types implemented by NimYAML, but you can -for example use it on a certain ``seq`` type: +`setTagUri`_. It may not 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 @@ -378,22 +382,20 @@ representObject proc representObject*( ctx : var SerializationContext, value: MyObject, - tag : TagId, + tag : Tag, ): {.raises: [YamlSerializationError].} This proc should push a list of tokens that represent the type into the serialization context via ``ctx.put``. Follow the following guidelines when implementing a custom ``representObject`` proc: -- You can use the helper template - `presentTag `_ - for outputting the tag. - Always output the first token with a ``yAnchorNone``. Anchors will be set automatically by ``ref`` type handling. - When outputting non-scalar types, you should use ``representChild`` for contained values. - Always use the ``tag`` parameter as tag for the first token you generate. -- Never write a ``representObject`` proc for ``ref`` types. +- Never write a ``representObject`` proc for ``ref`` types, instead write the + proc for the ref'd type. The following example for representing to a YAML scalar is the actual implementation of representing ``int`` types: diff --git a/doc/snippets/quickstart/01/01-in.yaml b/doc/snippets/quickstart/01/01-in.yaml index b918cbf..2a44902 100644 --- a/doc/snippets/quickstart/01/01-in.yaml +++ b/doc/snippets/quickstart/01/01-in.yaml @@ -1,4 +1,2 @@ -%YAML 1.2 ---- - { name: Karl Koch, age: 23 } - { name: Peter Pan, age: 12 } \ No newline at end of file diff --git a/doc/snippets/quickstart/04/01-in.yaml b/doc/snippets/quickstart/04/01-in.yaml index 6a3b0ab..13aece5 100644 --- a/doc/snippets/quickstart/04/01-in.yaml +++ b/doc/snippets/quickstart/04/01-in.yaml @@ -1,6 +1,4 @@ -%YAML 1.2 -%TAG !n! tag:nimyaml.org,2016: ---- !n!custom:NodeObj &a +--- &a name: Node 1 left: name: Node 2 diff --git a/doc/snippets/quickstart/08/00/00-code.nim b/doc/snippets/quickstart/08/00/00-code.nim index f8c0ff3..e725056 100644 --- a/doc/snippets/quickstart/08/00/00-code.nim +++ b/doc/snippets/quickstart/08/00/00-code.nim @@ -23,7 +23,7 @@ type of ckNone: discard -setTag(Person, nimTag("demo:Person")) +setTag(Person, Tag("!Person")) var list: seq[Container] diff --git a/doc/snippets/quickstart/08/00/01-in.yaml b/doc/snippets/quickstart/08/00/01-in.yaml index 7923272..600998c 100644 --- a/doc/snippets/quickstart/08/00/01-in.yaml +++ b/doc/snippets/quickstart/08/00/01-in.yaml @@ -1,9 +1,6 @@ -%YAML 1.2 -%TAG !n! tag:nimyaml.org,2016: ---- - this is a string - 42 - false - !!str 23 -- !n!demo:Person {name: Trillian} +- !Person {name: Trillian} - !!null \ No newline at end of file diff --git a/doc/snippets/quickstart/08/01/00-code.nim b/doc/snippets/quickstart/08/01/00-code.nim index 6923cf8..74a5685 100644 --- a/doc/snippets/quickstart/08/01/00-code.nim +++ b/doc/snippets/quickstart/08/01/00-code.nim @@ -2,7 +2,7 @@ import yaml, yaml/data, yaml/parser, yaml/hints, streams type Person = object name: string -setTag(Person, nimTag("demo:Person"), yTagPerson) +setTag(Person, Tag("!Person"), yTagPerson) var s = newFileStream("in.yaml", fmRead) diff --git a/doc/snippets/quickstart/08/01/01-in.yaml b/doc/snippets/quickstart/08/01/01-in.yaml index 10fff1b..f6a7209 100644 --- a/doc/snippets/quickstart/08/01/01-in.yaml +++ b/doc/snippets/quickstart/08/01/01-in.yaml @@ -1,8 +1,5 @@ -%YAML 1.2 -%TAG !n! tag:nimyaml.org,2016: ---- !!seq - this is a string - 42 - false - !!str 23 -- !n!demo:Person {name: Trillian} \ No newline at end of file +- !Person {name: Trillian} \ No newline at end of file diff --git a/yaml.nimble b/yaml.nimble index 6626b2c..4830b9d 100644 --- a/yaml.nimble +++ b/yaml.nimble @@ -1,10 +1,10 @@ # Package -version = "2.0.0" +version = "2.1.0" author = "Felix Krause" description = "YAML 1.2 implementation for Nim" license = "MIT" -skipDirs = @["bench", "doc", "server", "test", "tools"] +skipDirs = @[".github", "bench", "doc", "server", "test", "tools"] # Dependencies