ktoml
ktoml copied to clipboard
Implement `encodeToString`
This would be really useful in general
Duplicate of #11
Yeah, @NightEule5 and I started this work already:
There is mostly everything done - this should take 1-2 weekends and 5-6 bottles of beer to implement
By the way - why do you need encoding of TOML? Usually TOML is used as a config-file format and decoder is needed. How do you want to use encoder?
My use case the program will have some UI to change some of the values
So you plan to generate files in TOML format? Got it
Ya, if you guys have a branch up for the encoding I wouldn't mind contributing.
Ya, if you guys have a branch up for the encoding I wouldn't mind contributing.
Everything is merged - AST enhancements, annotations for encoding -> so no existing branch is there. We can easily split the remaining logic and give you some part of the work if you wish :)
I will provide task list in this issue
I have a draft implementation up on my fork now. I've gotta test and debug still, it's not quite working. Progress is being made :)
@NightEule5 any progress on this? if there's a branch somewhere I wouldn't mind helping out
@NightEule5 any progress on this? if there's a branch somewhere I wouldn't mind helping out
Everything's more or less working now, but the code is messier than I'd like. Here's the branch I'm working off of if you want to help or provide feedback. Perhaps it'd be easier if I created a draft pull request?
There are a few problems with it still:
- The
TomlCommentsannotation throws exceptions related to itsinlinedefault parameter. Nothing we can do about this, it's an issue with kotlinx.serialization that hasn't been fixed yet afaik - The
isSyntheticproperty inTomlTablewas made mutable, but that's a breaking change. I've been rewriting the encoders to defer table creation to theendStructurefunction to avoid this - Some formatting quirks persist with regards to indentation
- Annotations are inaccessible from property types, i.e.
val string: @TomlLiteral Stringproduces a normal string. Looks like another limitation of kotlinx.serialization, but I'm not sure how useful that would be anyway
Apologies for the slow progress, I've been sidetracked by another project lately