Commit graph

394 commits

Author SHA1 Message Date
Ethiraric
9d1bd1c929 Fix nightly warning. 2024-10-20 16:20:52 +02:00
Ethiraric
26707be38d Move CI from subprojects to root. 2024-10-17 19:25:19 +02:00
Ethiraric
59048f68ae Code cleanup after monorepo-ing. 2024-10-13 14:42:50 +02:00
David Aguilar
4e781f56c9 cargo: merge Cargo.toml files into a cargo workspaces 2024-10-04 00:35:06 -07:00
David Aguilar
3978720dc9 .gitignore: merge gitignores into a single top-level file 2024-10-04 00:34:35 -07:00
Ethiraric
5be327f855 Add changelog entry for last commit. 2024-09-25 16:32:56 +02:00
Ethiraric
fd5a606b19 Make LoadError Clone.
Fixes #11
2024-09-25 16:31:59 +02:00
Chris Gunn
1fc46923ef Fix multiline string emit.
Use `|-` instead of `|` when there is not a trailing newline
in the string value.
2024-07-09 16:27:58 +02:00
Ethiraric
d582b0fec9 Refactor to remove unnecessary unwrap. 2024-07-03 00:55:41 +02:00
Ethiraric
23c0b3c547 Move load_from_* functions in Yaml.
This would make more sense in user code:
```rs
Yaml::load_from_str("foo"); // Explicit that we're parsing YAML
load_from_str("foo"); // Too implicit, too generic, may be from another
                         lib
```

Plus, this mirrors `MarkedYaml`'s behavior.
2024-07-03 00:55:41 +02:00
Ethiraric
842d536cb0 Implement LoadableYamlNode for MarkedYaml.
A few changes have had to be made to `LoadableYamlNode`:
  * The `From<Yaml>` requirement has been removed as it can be
    error-prone. It was not a direct conversion as it is unable to
    handle `Yaml::Hash` or `Yaml::Array` with a non-empty array/map.
  * Instead, `from_bare_yaml` was added, which does essentially the same
    as `From` but does not leak for users of the library.
  * `with_marker` has been added to populate the marker for the `Node`.
    The function is empty for `Yaml`.

`load_from_*` methods have been added to `MarkedYaml` for convenience.
They load YAML using the markers.

The markers returned from `saphyr-parser` are not all correct, meaning
that tests are kind of useless for now as they will fail due to bugs
outside of the scope of this library.
2024-07-03 00:55:41 +02:00
Ethiraric
9ab8dd7c07 Update doccomments. 2024-07-03 00:55:41 +02:00
Ethiraric
d2caaf2ab3 Prepare the ground for annotated parsing.
* Make `YamlLoader` generic on the type of the `Node`. This is required
   because deeper node need to have annotations too.
 * Add a `LoadableYamlNode` trait, required for YAML node types to be
   loaded by `YamlLoader`. It contains methods required by `YamlLoader`
   during loading.
 * Implement `LoadableYamlNode` for `Yaml`.
 * Take `load_from_str` out of `YamlLoader` for parsing non-annotated
   nodes. This avoids every user to specify the generics in
   `YamlLoader::<Yaml>::load_from_str`.
2024-07-03 00:55:41 +02:00
Ethiraric
425f00ceb8 Add base support for annotated YAML objects. 2024-07-03 00:55:41 +02:00
Ethiraric
2b8eb3f62b Split yaml.rs into sizeable files. 2024-06-10 20:28:13 +02:00
David Aguilar
976007017d garden: yaml-rust2 -> saphyr 2024-04-08 23:37:22 -07:00
maddymakesgames
5b3fa958b8 add Error and Display impls for LoadError 2024-04-07 01:52:24 +02:00
Ethiraric
30b713d7a7 yaml-rust2 -> saphyr 2024-04-02 18:49:52 +02:00
Ethiraric
d618d06061 Messed up the MSRV. 2024-03-30 19:39:53 +01:00
Ethiraric
f166970a3e Use cargo features. 2024-03-30 19:24:54 +01:00
Alistair Francis
0f1dedc584 yaml: Implement IndexMut
This implements the IndexMut trait for Yaml. This allows indexing the
Yaml type while having a mutable reference.

Unlike the Index, this will panic on a failure. That is allowed as per
the Rust documentation [1]. We don't have the option of returning a
mutable reference to BAD_VALUE as that is unsafe. So instead we just
panic.

1: https://doc.rust-lang.org/std/ops/trait.IndexMut.html#tymethod.index_mut

Resolves: https://github.com/chyh1990/yaml-rust/issues/123
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Co-authored-by: Ethiraric <ethiraric@gmail.com>
2024-03-30 18:52:39 +01:00
Ethiraric
2642252f7f Add doc checks to before_commit. 2024-03-28 21:06:32 +01:00
David Aguilar
2dc9e2c13f maint: version-up and minimize where we mention the version
Remove the version number from tools/gen_large_yaml so that we
can avoid needing to update the version in two places.
2024-03-25 22:25:46 -07:00
David Aguilar
b5c9eec454 yaml-rust2 v0.8.0 2024-03-25 22:18:38 -07:00
David Aguilar
ae65040d3b CHANGELOG: mention the linguist development-related updates 2024-03-25 22:18:37 -07:00
David Aguilar
4a5ba3b499 garden: access yaml-rust2 pull requests as yaml-rust2/pull/* 2024-03-25 22:18:37 -07:00
David Aguilar
134a1672cc garden: update urls and remove old forks and links
We have the commits in git now.
2024-03-25 22:18:37 -07:00
Spenser Black
536e5f7ec4 Add linguist attributes for tests/*.rs.inc files
This informs Linguist (used by GitHub) that these files are Rust (they
are currently detected as C++). This also marks them as generated.
2024-03-25 20:11:04 +01:00
John Vandenberg
992c9c29fb fix typos 2024-03-25 14:52:44 +01:00
David Aguilar
37f52b7722 README: update the installation snippet to use yaml-rust2 0.7 2024-03-24 17:00:57 -07:00
David Aguilar
53b70cd93b README: add self-links to make things more discoverable
If someone lands on one of our forks on github there are still UI elements
that point them back to the original chyh1990 yaml-rust project.

Add links to make it easier to navigate back to the main fork when
viewing a yaml-rust2 fork.
2024-03-24 17:00:19 -07:00
David Aguilar
ddb6885a17 yaml: add YamlLoader::load_from_parser(&Parser)
Make it easier to load documents from a prebuilt Parser.
2024-03-25 00:06:10 +01:00
David Aguilar
cd2028aca7 parser: add Parser::new_from_str(&str) 2024-03-25 00:06:10 +01:00
David Aguilar
21738031e3 parser: fixup typos from github 2024-03-24 15:01:38 -07:00
David Aguilar
e9e428eeaf CHANGELOG: simplify the formatting and document YamlLoader::documents() 2024-03-24 14:45:52 -07:00
David Aguilar
2c7ecbf054 CHANGELOG: document the keep_tags API addition 2024-03-24 14:27:04 -07:00
David Aguilar
6ea41cc9a8 parser: add a test for keep_tags(false)
Co-authored-by: Ethiraric <ethiraric@gmail.com>
2024-03-24 14:21:33 -07:00
David Aguilar
dfaea08aa1 parser: better document keep_tags
Co-authored-by: Ethiraric <ethiraric@gmail.com>
2024-03-24 14:21:33 -07:00
David Aguilar
e0560cb232 parser: add an option to keep tags across multiple documents
Documents are self-contained and tags defined in the first document are not
visible to subsequent documents.

Add support for having tags that span across all documents by making the
clearing of tags in the parser opt-out.

Closes: #10
2024-03-24 14:21:33 -07:00
David Aguilar
a5550d4203 yaml: add YamlLoader::documents() to get a read-only view of the parsed documents 2024-03-24 14:21:33 -07:00
Ethiraric
eddea11e01 Switch from encoding to encoding_rs.
See https://github.com/rustsec/advisory-db/issues/1605.
2024-03-24 17:14:44 +01:00
Gregor Purdy
6052436852 Typo fix 4 in 2024-03-15-FirstRelease.md 2024-03-21 14:22:39 +01:00
Gregor Purdy
5b1af84dbe Typo fix 3 in 2024-03-15-FirstRelease.md 2024-03-21 14:22:14 +01:00
Gregor Purdy
759db28bfb Typo fix 2 in 2024-03-15-FirstRelease.md 2024-03-21 14:22:00 +01:00
Gregor Purdy
15049196e0 Typo fix 2024-03-21 14:21:26 +01:00
Ethiraric
7d3825c049 Remove no longer needed test files.
These tests were sucecssfully converted to Rust files to include and are
no longer necessary in this repository.
Should they become relevant again in the future, they can always be
checked out from a previous commit.
2024-03-21 12:37:10 +01:00
Ethiraric
61e26deb99 Run CI only on master pushes. 2024-03-21 12:33:00 +01:00
Ethiraric
869a2d1a15 Make gen_large_yaml reproductible.
* Use a seedable RNG so that we can have the same number sequence.
* Replace `HashMap`s with `Vec`s to avoid undeterministic iteration.
2024-03-20 23:07:08 +01:00
Ethiraric
e8415713ab Edit v0.6 post with cargo alias. 2024-03-20 21:39:38 +01:00
Ethiraric
898dab9851 Fix rustdoc ignore directive. 2024-03-20 16:00:33 +01:00