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

Add yaml/yml formatting support #540

Open
hazendaz opened this issue Nov 25, 2021 · 4 comments
Open

Add yaml/yml formatting support #540

hazendaz opened this issue Nov 25, 2021 · 4 comments

Comments

@hazendaz
Copy link
Member

We could benefit from adding yaml support. I believe Jackson can do this but have not explored that. I did look at and try to code a working example with snakeyaml. It can at least take an extremely poorly formatted file and straighten it up but their pretty print does practically nothing to fix spacing. As yaml files are highly sensitative to spacing, if we do this we may have to get some work on upstream snakeyaml since it has pretty print option and possibly use our newer trailing space removal. There are some tools in the IDEs that do address formatting so there is possibly some adaptation of some item used in say eclipse that might work out better. Open to ideas and see some real value in formatting those files as well.

@ctubbsii
Copy link
Member

I really worry about this plugin getting too bloated. More languages means more dependencies to download, even if users don't have any need for that part of this plugin.

I think long-term, this plugin needs to either:

  1. be made extensible, so dependencies for optional features aren't required for users not needing those features (spotbugs-maven-plugin is extensible this way), or
  2. (my preference) Create a series of more narrowly-scoped plugins, that each format a single type, rather than have a single bloated plugin.

In the near-term, if there's an easy way to add yaml support and somebody is willing to do that work, I say go ahead. It will just be more features I won't use. 😺

@XenoAmess
Copy link
Contributor

We could benefit from adding yaml support. I believe Jackson can do this but have not explored that. I did look at and try to code a working example with snakeyaml. It can at least take an extremely poorly formatted file and straighten it up but their pretty print does practically nothing to fix spacing. As yaml files are highly sensitative to spacing, if we do this we may have to get some work on upstream snakeyaml since it has pretty print option and possibly use our newer trailing space removal. There are some tools in the IDEs that do address formatting so there is possibly some adaptation of some item used in say eclipse that might work out better. Open to ideas and see some real value in formatting those files as well.

@hazendaz
jackson can't.
whether writerWithDefaultPrettyPrinter or writer , jackson will just write multiple-line texts in one same line, which is not beautiful.

@XenoAmess
Copy link
Contributor

I used a test file from https://stackoverflow.com/questions/24418449/pretty-output-with-pyyaml

- color green :
     inputs :
        - port thing :
            widget-hint : filename
            widget-help : Select a filename
        - port target_path : 
            widget-hint : path
            value : 'thing' 
     outputs:
        - port value:
             widget-hint : string
     text : |
            I'm lost and I'm found
            and I'm hungry like the wolf.

and jackson would always print

- color green:
    inputs:
    - port thing:
        widget-hint: "filename"
        widget-help: "Select a filename"
    - port target_path:
        widget-hint: "path"
        value: "thing"
    outputs:
    - port value:
        widget-hint: "string"
    text: "I'm lost and I'm found\nand I'm hungry like the wolf.\n"

not beautiful at all.

@XenoAmess
Copy link
Contributor

XenoAmess commented Feb 10, 2022

I really worry about this plugin getting too bloated. More languages means more dependencies to download, even if users don't have any need for that part of this plugin.

I think long-term, this plugin needs to either:

  1. be made extensible, so dependencies for optional features aren't required for users not needing those features (spotbugs-maven-plugin is extensible this way), or
  2. (my preference) Create a series of more narrowly-scoped plugins, that each format a single type, rather than have a single bloated plugin.

In the near-term, if there's an easy way to add yaml support and somebody is willing to do that work, I say go ahead. It will just be more features I won't use. 😺

@ctubbsii

I strongly prefer 1 than 2.

It will be hard to manage the codes if you choose way 2, really hard.

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

No branches or pull requests

3 participants