Skip to content

Commit

Permalink
Simplified docs, fixed some links. v2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flyx committed Dec 30, 2023
1 parent cdbf426 commit eee4568
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 36 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 2.1.0 (upcoming)
## 2.1.0

Features:

Expand Down Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions doc/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
============
Expand Down
32 changes: 17 additions & 15 deletions doc/serialization.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <api/dumping.html#dump%2CDumper%2CK>`_
and `load <api/loading.html#load%2C%2CK>`_. 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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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 <api/taglib.html#setTagUri.t%2Ctypedesc%2Cstring>`_. 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

Expand Down Expand Up @@ -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 <api/native.html#presentTag%2CSerializationContext%2Ctypedesc>`_
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:
Expand Down
2 changes: 0 additions & 2 deletions doc/snippets/quickstart/01/01-in.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
%YAML 1.2
---
- { name: Karl Koch, age: 23 }
- { name: Peter Pan, age: 12 }
4 changes: 1 addition & 3 deletions doc/snippets/quickstart/04/01-in.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/snippets/quickstart/08/00/00-code.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type
of ckNone:
discard

setTag(Person, nimTag("demo:Person"))
setTag(Person, Tag("!Person"))

var list: seq[Container]

Expand Down
5 changes: 1 addition & 4 deletions doc/snippets/quickstart/08/00/01-in.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion doc/snippets/quickstart/08/01/00-code.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions doc/snippets/quickstart/08/01/01-in.yaml
Original file line number Diff line number Diff line change
@@ -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}
- !Person {name: Trillian}
4 changes: 2 additions & 2 deletions yaml.nimble
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit eee4568

Please sign in to comment.