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

emit formatting #37

Open
biojppm opened this issue Feb 7, 2020 · 4 comments
Open

emit formatting #37

biojppm opened this issue Feb 7, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@biojppm
Copy link
Owner

biojppm commented Feb 7, 2020

Eg, #29 or #30 . Some thoughts:

  • implement custom EmitFormatters:
    • block (the current emitter)
    • single-line flow
    • multi-line flow
    • semi-intelligent: use a general emitter, using heuristics such as counting columns and breaking and selecting block/flow styles as appropriate (eg, nested containers)
  • implement per-node format flags? i.e., add flags forcing format selection?
  • add type-based implicit tagging? e.g. implicit tag bools so that they show as "true" rather than "1"
@biojppm biojppm added the enhancement New feature or request label Feb 7, 2020
@biojppm biojppm self-assigned this Feb 7, 2020
@leoetlino
Copy link
Contributor

Sounds good to me. Per-node flags would be very useful, since it would let users override the style and get exactly what they want. I assume there'd be three flags, block/flow/auto, with block being set by default?

Another thing that would be nice to have is the ability to enable wrapping (by setting a maximum line width). With all these additions ryml would be on par with libyaml for formatting options.

add type-based implicit tagging? e.g. implicit tag bools so that they show as "true" rather than "1"

Could this not be achieved just by changing the format overload for bool to give "true"/"false" rather than 0/1, or am I missing something?

@rysavyjan
Copy link

I'm using Rapid YAML for merging YAML output from clang-tidy into replacements file.

Now is following input

ReplacementText: "#ifndef E:\\SOURCE\\FINE\\COMMON\\GRAPHICSUTILS_H\n#define E:\\SOURCE\\FINE\\COMMON\\GRAPHICSUTILS_H\n\n"

emitted as

ReplacementText: |+
  #ifndef E:\SOURCE\FINE\COMMON\GRAPHICSUTILS_H
  #define E:\SOURCE\FINE\COMMON\GRAPHICSUTILS_H

It would be great to have option to output value in the original format.
I assume it is not possible with current ryml version? (I will probably use some dirty hack for my use case.)

@biojppm
Copy link
Owner Author

biojppm commented Feb 21, 2021

@rysavyjan sorry for the late reply, somehow I missed your post.

You are correct; at the moment ryml does not implement this. This issue is meant to track progress in formatting, but I've not been able to do anything since I opened it. I also won't be able to come back to this in the next month or two.

@captain-yoshi
Copy link
Contributor

Feedback and ideas from using _WIP_STYLE_FLOW_SL:

_WIP_STYLE_FLOW_SL = c4bit(14), ///< mark container with single-line flow format (seqs as '[val1,val2], maps as '{key: val, key2: val2}')
_WIP_STYLE_FLOW_ML = c4bit(15), ///< mark container with multi-line flow format (seqs as '[val1,\nval2], maps as '{key: val,\nkey2: val2}')

// sequences should perhaps have a whitespace between each commas to behave like the map.
// ex. [val1, val2]

// Or you could have a default (white-space seperated) and a compact one
_WIP_STYLE_FLOW_SL             // [val1, val2]
_WIP_STYLE_FLOW_SL_COMPACT     // [val1,val2]

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

No branches or pull requests

4 participants