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

Meson format #12318

Merged
merged 8 commits into from
Apr 8, 2024
Merged

Meson format #12318

merged 8 commits into from
Apr 8, 2024

Conversation

bruchar1
Copy link
Member

@bruchar1 bruchar1 commented Oct 2, 2023

This is a native meson format command, similar to muon fmt.

mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
mesonbuild/mformat.py Fixed Show fixed Hide fixed
@bruchar1 bruchar1 force-pushed the meson-format branch 6 times, most recently from 7972813 to 0df9d99 Compare October 3, 2023 13:47
@tristan957
Copy link
Contributor

cc @JCWasmx86

@JCWasmx86
Copy link
Contributor

Thanks for pinging me tristan957, I closed #10971

@bruchar1
Copy link
Member Author

rebased, and targeted for 1.4.0

docs/markdown/Commands.md Outdated Show resolved Hide resolved
Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few of these commits could use more detailed commit messages.

The first one I suspect (though I haven't checked) was originally only for keyword arguments so column made sense, and stopped making sense as we extended it to additional places.

Overall I like this a lot, and while there's some additional things I'd like to handle here, I think those are fine follow ons.

I t would be nice if meson format would automatically load a meson.format file that was at the root of the source directory so that proejcts could just run meson format and not have to worry about passing in the format rules if they're defined globally

docs/markdown/Commands.md Outdated Show resolved Hide resolved
docs/markdown/Commands.md Show resolved Hide resolved
mesonbuild/mformat.py Outdated Show resolved Hide resolved
bruchar1 added 8 commits April 5, 2024 14:42
- Wrong types were used for MultilineStringNode and
  FormatMultilineStringNode
- Simplify the `escape` method to avoid use of T.Cast
In #02ff955, I used the word `columns` instead of `colons`, but the
meaning really was about the ':' symbol.
The `AstVisitor` intentionally ignores whitespaces and symbols,
as they are not useful for tne interpreter. However, when formatting a
build file, we need them. This commit introduces a `FullAstVisitor` that
visits every Nodes, including whitespaces and symbols.
Use the new `FullAstVisitor` for `AstConditionLevel`. This will allow
proper formatting of `if / else / endif` and `foreach / endforeach`
blocks.
this will allow transforming string types in the formater
@bruchar1
Copy link
Member Author

bruchar1 commented Apr 5, 2024

A few of these commits could use more detailed commit messages.

I tried to improve it. But I am open to suggestions...

I t would be nice if meson format would automatically load a meson.format file that was at the root of the source directory so that proejcts could just run meson format and not have to worry about passing in the format rules if they're defined globally

Done. Will also automatically analyse meson.build in current directory if it is present and no other build files are specified on the command line.

Copy link
Member

@dcbaker dcbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@dcbaker dcbaker merged commit 2b37101 into mesonbuild:master Apr 8, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants