jenius/roots — pull request #238 by jenius (2013-10-03 20:40:29+00:00)
Title: Compiler restructure

Huge huge rewrite of the compiler's core. There really is no way to make it uncomplicated, but the aim here was to restrict complexity to one place and make it more extensible. What happened is summarized below:

- Compiler now adheres to the decorator pattern. Extensions can be registered with the compiler and are allowed to "hook" into a couple important spots in the compile process and have a lot of power to modify any part of the process.
- Multiple extensions can be registered and can run hooks on the same spots.
- Dynamic content handling and layout handling have been pulled out into extensions.
- The core compile process has been tightened up to only include direct compilation tasks and hooks. That being said this is a very confusing and difficult piece of code to handle, since it can get down with multiple files compiling at once, each one async multiple extensions running on hooks at once, each one with the potential to be async, and multiple compile passes on each file, with more hooks nested inside those. There is a lot of insane async handling in the core compiler in order to make it flexible enough to pull out the extensions. I don't think it can be cleaned up much more than it currently is, but if anyone wants to take a stab, you are welcome to. Since it is by far the most difficult piece of code in roots, I left a lot of very thorough comments explaining what's going on at each step.
- The file helper class, which was really a mess, has been slimmed down to almost nothing.

Tests are passing, and it correctly compiles http://carrot.is, my two biggest tests for any modifications to roots. I'd love to get you guys' feedback on this before it's merged into transformers.