Discussion:
[dart-misc] How dartfmt works
'Bob Nystrom' via Dart Misc
2015-09-09 22:09:22 UTC
Permalink
Now that more of you are running dartfmt, I get a lot of questions about
how it works its magic. There are actually two related questions here:

1. What is the set of formatting rules and constraints it is trying to
apply? In other words, what is its mental model of the style guide?

2. How are those rules implemented and solved efficiently?

I should really write down answers both questions. The former is probably
the more relevant one, and the shorter one to answer. Somehow, I ended up
writing the latter first.

If you'd like a very detailed walkthrough of how the formatter works
internally, I wrote a long blog post about it here
<http://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/>.
You could also just read the source (which I am ashamed to admit may be
shorter than the blog post), but what's the fun in that?

Cheers!

- bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Don Olmstead
2015-09-09 22:45:57 UTC
Permalink
Great blog post Bob. I've been using dartfmt programmatically when
generating code and for the most part I like the output. Have a couple nits
about it but overall great work on your end!

On Wed, Sep 9, 2015 at 3:09 PM, 'Bob Nystrom' via Dart Misc <
Post by 'Bob Nystrom' via Dart Misc
Now that more of you are running dartfmt, I get a lot of questions about
1. What is the set of formatting rules and constraints it is trying to
apply? In other words, what is its mental model of the style guide?
2. How are those rules implemented and solved efficiently?
I should really write down answers both questions. The former is probably
the more relevant one, and the shorter one to answer. Somehow, I ended up
writing the latter first.
If you'd like a very detailed walkthrough of how the formatter works
internally, I wrote a long blog post about it here
<http://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/>.
You could also just read the source (which I am ashamed to admit may be
shorter than the blog post), but what's the fun in that?
Cheers!
- bob
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...