Introducing a mojom formatter

37 views
Skip to first unread message

Alexandre

unread,
Feb 29, 2016, 6:31:43 PM2/29/16
to mojo-dev
If you don't care about mojom, you can stop reading now.

Building on the new mojom parser, we wrote a mojom formatter. You can invoke it in the mojo repo like thus: (Sync to head and run gclient sync)

./mojo/public/tools/bindings/mojom_tool/bin/linux64/mojom fmt <file/to/reformat.mojom>

Using the -w option will overwrite the specified file with the formatted content.

To show the sort of changes, that may happen, I have created an issue with the whole mojo repo formatted:


Some highlights:
Each attribute is now on its own line where appropriate.
Comments are properly indented.
The last enum value of an enum ends with a comma.
Empty structs are collapsed to a single line.

The idea is that the formatter will free us from having to think about formatting issues in mojom and could ideally be run on every save and as part of the presubmit checks. Please file bugs if you have any concern with the formatting.

azani

Viet-Trung Luu

unread,
Feb 29, 2016, 6:47:58 PM2/29/16
to Alexandre, mojo-dev
Thanks, this looks like a great start!

But before everyone goes out and (re)formats all their mojom files, we should probably have some style bikeshedding first. ;-)

(Once that's done, maybe we can hook it into git cl format, or at least a presubmit check....)

--
You received this message because you are subscribed to the Google Groups "mojo-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mojo-dev+u...@chromium.org.

Reply all
Reply to author
Forward
0 new messages