Update the main documentation with new magics API.

Added detailed description to the docs, as well as comprehensive
examples of magic creation with the new APIs.
Add missing shebang line to post_pr_test script.
Merge pull request #1732 from fperez/cellmagics

Refactoring of the magics system and implementation of cell magics.

This PR completely refactors the magic system, finally moving the magic objects to standalone, independent objects instead of being the mixin class we'd had since the beginning of IPython.  Now, a separate base class is provided in IPython.core.magic.Magics that users can subclass to create their own magics.  Decorators are also provided to create magics from simple functions without the need for object orientation.

All builtin magics now exist in a few subclasses that group together related functionality, and the new IPython.core.magics package has been created to organize this into smaller files.

This cleanup was the last major piece of deep refactoring needed from the original 2001 codebase.

Secondly, this PR introduces a new type of magic function, prefixed with `%%` instead of `%`, which operates at the cell level.  A cell magic receives two arguments: the line it is called on (like a line magic) and the body of the cell below it.

Cell magics are most natural in the notebook, but they also work in the terminal and qt console, with the usual approach of using a blank line to signal cell termination.

This PR closes #1611, or IPEP 1, where the design had been discussed.
Fix doctests that relied on dict ordering in IPython.utils
Make repr-reliant test less specific
Fix more cases relying on dict ordering in utils
Fix tests relying on dict order in IPython.config
Fix tests that depended on dictionary order in IPython.core
teardown changes to sys.path
For doctests, globals must now be a real dictionary.
Call invalidate_caches() when testing installing extension.
Ensure modules for autoreload have a __loader__ attribute.
timeit.template uses new-style string formatting from Python 3.3
Merge pull request #1763 from Carreau/fix_plain_html

[qtconsole] fix typo append_plain_html -> append_html
cleanup parallel magics

* remove unused run_code override
* use formatting to build composite docstring
* update docstring
* remove `__init__` that had been reduced to a no-op
* raise UsageError on no active view
Merge pull request #1716 from takluyver/verbose-tb

Fix for fake filenames in verbose traceback.

We use in our frames fake filenames of the type `<ipython....>`, and we relied on `abspath` throwing an `OSError` exception with them.  That is no longer the case, and it leads to verbose tracebacks not inspecting IPython frames correctly.

This fixes the issue by simply assuming that any file that starts/ends with `</>` can't be a normal python file, which is a sensible policy (for one thing, such names can't be imported).
displaypub b64 encoding is non-destructive

`_encode_binary` helper fund encoded in-place, which is destructive
if the dict is ever re-used.

also prevents double-encoding, by only encoding bytes objects, since unicode objects are necessarily already encoded.
add colored repr_pretty to ExecuteReply
restore %result functionality

It now does what it once did in the days of Twisted long ago:
display the output of the most recent command (e.g. after async %px).
skip get_dict call in parallel magics