Commit Graph

92 Commits

Author SHA1 Message Date
Lukas Kalbertodt
6a9ccd4e22 Do major refactor of format code
This gets rid of a lot of duplicated logic that was previously
copy&pasted. This commit alos:
- Makes it easier to implement new formats
- Gets rid of a few bugs
- Makes the system more flexible (more options)
- Adds a lot of additional tests
2022-10-19 17:12:32 +02:00
Lukas Kalbertodt
44f59f415a Implement Serialize for meta::Expr and use it in PrintExpr
This probably fixes a few edge case bugs (float infinity and stuff) and
results in less code.
2022-10-19 17:10:17 +02:00
Lukas Kalbertodt
4f5c458150 Add YAML formatting tests 2022-10-19 10:12:25 +02:00
Lukas Kalbertodt
736584ad9d Fix incorrect newlines in yaml::format 2022-10-19 10:11:33 +02:00
Lukas Kalbertodt
dd55a17b14 Show env key in config template 2022-10-18 16:07:51 +02:00
Lukas Kalbertodt
d03d1e0799 Add tests checking many of the standard usages of this lib 2022-10-17 17:55:30 +02:00
Lukas Kalbertodt
30fbc4f256 Fix name clash issue of helper deserialize functions 2022-10-17 17:14:01 +02:00
Lukas Kalbertodt
075078ac89 Slightly simplify generated code 2022-10-17 14:50:53 +02:00
Lukas Kalbertodt
52cea84028 Add test for array default values 2022-10-17 12:38:05 +02:00
Lukas Kalbertodt
37bb6b6b14 Add PartialEq impls to all meta items
This is useful for unit-testing but also generally usable. So why not.
2022-10-17 12:37:22 +02:00
Lukas Kalbertodt
4c40a35959 Move code around in macro crate 2022-10-17 11:55:29 +02:00
Lukas Kalbertodt
f0895a8b2f Add support for array default values 2022-10-17 11:29:38 +02:00
Lukas Kalbertodt
0677f751aa Fix bug with float type inference for meta::Expr 2022-10-16 20:13:56 +02:00
Lukas Kalbertodt
5c3315b015 Move to Rust edition 2021 2022-10-14 16:42:49 +02:00
Lukas Kalbertodt
90344ebd36 Bump version to 0.1.4 v0.1.4 2022-10-14 16:33:37 +02:00
Lukas Kalbertodt
eb03488973 Fix using env with deserialize_with
Fixes #2

I simply forgot to use the `deserialize_with` attribute for the env
deserialization. The previous code was somewhat weirdly coded in that
we would always deserialize `Option<T>` (as it's a partial type) and
the "env variable not present" info would travel through the
deserializer to the `Option<T> as Deserialize` impl. Now it's more
straight forward.
2022-10-14 16:33:37 +02:00
Lukas Kalbertodt
04f7f6b3be Remove leftover comment 2022-10-11 15:15:09 +02:00
Lukas Kalbertodt
6f8ff66f29 Use proper action for Rust caching in CI 2022-10-11 13:22:30 +02:00
Lukas Kalbertodt
963e4745a3 Allow unused test utility
This is only unused with `--no-default-features`.
2022-10-11 13:17:19 +02:00
Lukas Kalbertodt
65d0b7ca17 Fix minor docs formatting issue 2022-10-11 12:59:54 +02:00
Lukas Kalbertodt
6c35c85008 Bump version to 0.1.3 v0.1.3 2022-04-07 17:29:12 +02:00
Lukas Kalbertodt
56f8ff24d5 Improve toml::format regarding space above nested objects 2022-04-07 17:19:38 +02:00
Lukas Kalbertodt
8db8fcafc4 Add two toml::format tests 2022-04-07 14:00:56 +02:00
Lukas Kalbertodt
ed141ab54d Fix generation bug for pub and pub(in path) structs 2022-04-07 13:59:09 +02:00
Lukas Kalbertodt
6c9f398065 Allow unused fields in example
This fails now because access by `derive(Debug)` are not counted as
actual reads anymore as far as that lint is concerned.
2022-03-30 17:41:51 +02:00
Lukas Kalbertodt
2f0f749c74 Bump version to 0.1.2 and adjust changelog v0.1.2 2022-03-30 17:39:05 +02:00
Lukas Kalbertodt
1c6ecdd4ad Fix doctests using derive
See https://github.com/rust-lang/rust/issues/83583
2022-03-30 17:38:39 +02:00
Lukas Kalbertodt
e801403009 Fix output of toml::format by always handling leaf fields first
Otherwise this:

```
struct Config {
    #[config(nested)]
    foo: ...,
    bar: ...,
}
```

would emit:

```
[foo]

```

Which is incorrect.
2022-03-30 16:15:27 +02:00
Lukas Kalbertodt
cc1681bf53 Bump version to 0.1.1 v0.1.1 2021-11-03 16:09:13 +01:00
Lukas Kalbertodt
a50f78e938 Add deserialize_with attribute that is forwarded to serde 2021-11-03 16:01:57 +01:00
Lukas Kalbertodt
a54042f8ca Revert "Replace some manual parsing code with darling helper crate"
This reverts commit e5af4f8efe.

The `darling` crate limits us to `syn::Meta` which is probably not
enough in the long run. There are a couple of other problems I have
with this crate and I think it's currently not worth. I'm considering
writing my own alternative...
2021-11-03 14:58:23 +01:00
Lukas Kalbertodt
e5af4f8efe Replace some manual parsing code with darling helper crate 2021-11-03 11:46:33 +01:00
Lukas Kalbertodt
608b978341 Slightly improve derive error message for nested fields not impl Config 2021-10-26 16:19:33 +02:00
Lukas Kalbertodt
3c5b72220a Improve derive error messages when fields don't implement Deserialize 2021-10-26 16:19:33 +02:00
Lukas Kalbertodt
4f4f42e8f3 Disable some code (and fix others) when no features are enabled v0.1.0 2021-07-28 12:38:50 +02:00
Lukas Kalbertodt
1a8e9440cc Minor README improvements 2021-07-28 12:16:13 +02:00
Lukas Kalbertodt
a326afa4b1 Add changelog 2021-07-28 12:12:44 +02:00
Lukas Kalbertodt
f0648d722e Prepare macro crate for release 2021-07-28 12:11:32 +02:00
Lukas Kalbertodt
e35be71665 Add metadata to Cargo.toml 2021-07-28 12:09:04 +02:00
Lukas Kalbertodt
b7515239e5 Remove useless dev-dependencies 2021-07-28 12:06:04 +02:00
Lukas Kalbertodt
313d143486 Remove Debug impls and syn's extra-trait features 2021-07-28 12:03:43 +02:00
Lukas Kalbertodt
8a520927a2 Add crate-level documentation 2021-07-28 12:02:09 +02:00
Lukas Kalbertodt
276e9a30cd Add comparisons to other libraries to README 2021-07-27 18:01:49 +02:00
Lukas Kalbertodt
69142ceaeb Add README 2021-07-27 17:43:09 +02:00
Lukas Kalbertodt
00dbe4dc0a Fix compilation failure for --no-default-features 2021-07-27 17:16:06 +02:00
Lukas Kalbertodt
cdda7c5303 Add GitHub Actions CI script 2021-07-27 17:12:24 +02:00
Lukas Kalbertodt
c904181b6b Add license 2021-07-27 16:32:26 +02:00
Lukas Kalbertodt
cc1a0eba5e Minor documentation improvements 2021-07-27 16:20:24 +02:00
Lukas Kalbertodt
a86ab50588 Add more documentation to Config trait and derive 2021-07-27 16:15:05 +02:00
Lukas Kalbertodt
78b2db26e1 Allow multiple attributes in one #[config(...)]
E.g. `#[config(env = "FOO", default = 3)]`
2021-07-27 16:14:49 +02:00