Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotted keys cause tomllib to fail to parse Cargo.toml #15

Closed
wraithan opened this issue Jan 19, 2019 · 6 comments
Closed

dotted keys cause tomllib to fail to parse Cargo.toml #15

wraithan opened this issue Jan 19, 2019 · 6 comments

Comments

@wraithan
Copy link
Owner

wraithan commented Jan 19, 2019

This was initially reported on #9

Contenders for new TOML crate to replace tomllib.

  • toml_edit - Built for cargo_edit with an very similar feature set required (may eventually see about getting bump integrated as part of cargo_edit)
    • Can preserve most formatting
      • Misses cases where the same header appears multiple times with different formats
      • Misses whitespace in headers
      • Can't find a way to preserve the whitespace around the replaced string with currently exposed data from toml_edit
      • Always adds trailing newline to file
    • Test suite includes dotted key case that causes trouble
    • Established history, maintenance within the last few months
  • toml-rs - A more general purpose toml library
    • Does not preserve formatting at all
    • Extensive test suite
    • Established history, maintenance within the last few days
@wraithan
Copy link
Owner Author

tomllib has not had a release or commit to master in ~3 years. toml-edit was recommended by @gyscos in #9 as it is used in cargo-edit. I want to survey any other libraries that can fit the bill before committing to one, as this is the second time the library I was using has died.

@wraithan
Copy link
Owner Author

toml-rs was recommended here: #10 (comment)

@wraithan
Copy link
Owner Author

Going to start on this issue by building a test suite that is agnostic to the toml crate. Since the needs from the TOML crate are pretty specific (format preservation) but only has to read/update a single value it should be easy enough to build the different impls once I get the test suite built. Should have had a suite for a while anyway.

@wraithan
Copy link
Owner Author

927fb3d Adds a basic test suite and factors the tomllib usage into a single function. Next up build implementations using toml_edit and toml-rs

@wraithan
Copy link
Owner Author

Updated top post, toml-rs is not suitable at all, it doesn't preserve comments or formatting.

toml_edit mostly fits the bill, but omits the cases with whitespace in the headers. The ability to parse the cases that tomllib failed on makes up for that problem though.

Moving forward with toml_edit will have to 2.0 since the whitespace preservation is changing which may break some use cases

@wraithan
Copy link
Owner Author

4ce6ae3

Fixes this, uses toml_edit as was recommended (and an implementation provided by) @gycos. Didn't use their patch mostly because I had to refactor the code for testing first. Will pull in their other patch for pre-release and meta data before 2.0 release goes out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant