2015-12-29 17:38:22 +00:00
# NimYAML - YAML implementation for Nim
2021-10-22 16:36:29 +00:00
![Test Status ](https://github.com/flyx/NimYAML/actions/workflows/action.yml/badge.svg )
2016-09-20 16:33:52 +00:00
2016-06-08 19:28:07 +00:00
NimYAML is a pure Nim YAML implementation without any dependencies other than
Nim's standard library. It enables you to serialize Nim objects to a YAML stream
2022-07-10 21:24:25 +00:00
and back. It also provides a low-level event-based API.
2015-12-29 17:38:22 +00:00
2016-06-08 19:28:07 +00:00
Documentation, examples and an online demo are available [here][1]. Releases are
available as tags in this repository and can be fetched via nimble:
nimble install yaml
2021-05-17 22:57:01 +00:00
2018-08-30 07:49:02 +00:00
## Status
2016-06-08 19:28:07 +00:00
2022-07-10 21:24:25 +00:00
This library is stable.
2023-09-06 21:59:40 +00:00
NimYAML passes all tests of the current [YAML 1.2 test suite][4].
This project follows [SemVer][5].
2018-08-30 07:49:02 +00:00
2023-09-06 21:59:40 +00:00
I am committed to maintaining the library, but will seldom introduce new features.
PRs are welcome.
2018-08-30 07:49:02 +00:00
2023-09-06 21:59:40 +00:00
## Dependencies
2015-12-29 17:38:22 +00:00
2023-09-06 21:59:40 +00:00
NimYAML requires Nim 2.0.0 or later.
The last version supporting Nim 1.6.x is `v1.1.0` .
Use this in your `.nimble` file if you haven't migrated to Nim 2.x yet:
```nim
requires "yaml ^= 1.1.0"
```
## Missing Features
Be aware that serialization currently doesn't support the following features in types that are used for loading and dumping:
* Polymorphism: If a field has a type `ref Parent` , you cannot load a `ref Child` into it.
* Generic objects: The code auto-generating loading and dumping functions currently cannot process instances of generic objects anywhere in the type you want to load/dump.
* Default values: NimYAML uses its own `{.defaultVal: "foo".}` pragma.
It currently cannot process default values introduced in Nim 2.0.
2015-12-29 17:38:22 +00:00
2016-02-16 10:05:36 +00:00
## Developers
2023-09-06 21:59:40 +00:00
Nix users can `nix develop` to get a devshell with the required Nim version. You'll need to have Flakes enabled.
2016-02-16 10:05:36 +00:00
```bash
2020-10-04 20:18:15 +00:00
nim test # runs all tests
2016-10-09 13:05:18 +00:00
nim lexerTests # run lexer tests
nim parserTests # run parser tests (git-clones yaml-dev-kit)
2023-08-30 20:48:58 +00:00
nim nativeTests # runs native value tests
2016-10-09 13:05:18 +00:00
nim quickstartTests # run tests for quickstart snippets from documentation
2016-02-16 10:05:36 +00:00
nim clean # guess
nim build # build a library
```
2018-10-09 16:25:55 +00:00
When debugging crashes in this library, use the `d:debug` compile flag to enable printing of the internal stack traces for calls to `internalError` and `yAssert` .
2022-06-03 23:45:41 +00:00
### Web Documentation
2024-06-26 09:04:34 +00:00
The online documentation on [nimyaml.org][1], including the
2023-09-06 21:59:40 +00:00
testing ground, is generated via [Nix Flake][3].
You can build & run the docs server at via
```bash
nix run .#webdocs
```
It can be deployed to NixOS by importing the Flake's NixOS module and then doing
2022-06-03 23:45:41 +00:00
```nix
services.nimyaml-webdocs.enable = true;
```
2023-09-06 21:59:40 +00:00
This will run the documentation server locally at `127.0.0.1:5000` .
Since there isn't much of a use-case for third parties to host this documentation, there is no support for running the server without Nix.
2022-06-03 23:45:41 +00:00
2015-12-29 17:38:22 +00:00
## License
2016-06-08 19:28:07 +00:00
[MIT][2]
2021-10-22 16:36:29 +00:00
## Support this Project
2023-09-06 21:59:40 +00:00
If you want to support this project financially, there's a GitHub Sponsor button to the right.
2021-10-22 16:36:29 +00:00
2024-06-26 09:04:34 +00:00
[1]: https://nimyaml.org
2017-06-30 14:34:02 +00:00
[2]: copying.txt
2022-07-10 21:24:25 +00:00
[3]: https://nixos.wiki/wiki/Flakes
2023-09-06 21:59:40 +00:00
[4]: https://github.com/yaml/yaml-test-suite
[5]: https://semver.org