Skip to content

Add Display impls for directive#114

Closed
jakobhellermann wants to merge 1 commit intojcornaz:mainfrom
jakobhellermann:display-impls
Closed

Add Display impls for directive#114
jakobhellermann wants to merge 1 commit intojcornaz:mainfrom
jakobhellermann:display-impls

Conversation

@jakobhellermann
Copy link
Copy Markdown
Contributor

@jakobhellermann jakobhellermann commented Jan 31, 2026

Even if this library is not meant do modify beancount syntax in place, it's still useful to be able to print a directive in a readable way that corresponds to actual beancount code.

This PR, specifically d54defe, adds Display impls for Directive and its component types.

The impls aren't exactly syntax preserving, e.g. floats get normalized 50.0 -> 50, spaces get removed etc.

Maybe there should also be a comment somewhere that these display impls aren't guaranteed to be stable across semver non-breaking versions.

builds on top of #113 for stable order

@jakobhellermann jakobhellermann force-pushed the display-impls branch 2 times, most recently from d2ee167 to 5ccffc3 Compare February 8, 2026 20:36
These all emit parsable beancount code, but don't promise to keep the
exact syntax. E.g. floats are normalized, spacing gets removed.
@jcornaz
Copy link
Copy Markdown
Owner

jcornaz commented Mar 26, 2026

Hi, thank you for your contribution, and sorry for the delayed answer.

It took me a while to decide what I think about this, but I eventually reached the opinion that this can and should be implemented on the consuming side. There's too much opinions on what would be the correct rendering strategy, and this library's only purpose is to parse beancount syntax, not to produce it.

Nevertheless thank you again for the contribution.

@jcornaz jcornaz closed this Mar 26, 2026
@jakobhellermann jakobhellermann deleted the display-impls branch March 26, 2026 11:34
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

Successfully merging this pull request may close these issues.

2 participants