doc: Rebase Sphinx extensions from matplotlib.

Drop plot_directive in favour of using the extension provided by
matplotlib. Also, rebase gen_gallery to matplotlib 1.2.0. It's
unfortunate that it doesn't supply this extension itself, though.

Also, I made gen_gallery more PEP8 compliant than the original.
doc: Cleanup and fix front page's random image view.

Using the already-generated random_image.js, shuffle list of images, and
then pick the first 5 for display. Since the image paths are no longer
hard-coded, this should work with matplotlib 1.2 and 1.3+.

Additionally, fix layout of the sample images. The links and the images
are 'float'd but there is no 'clear'ing of the floating, so the body
actually ends before them.

Finally, CSS-ify bullets under the slideshow.
doc: Clean up Sphinx extensions.

In general, make Sphinx extensions PEP8 compliant. Use more modern
idioms, such as the built-in Sphinx file-inclusion commands, the `with`
statement, `open` instead of the `file` type, and the format function
instead of % string interpolation.
doc: Make package sidebar smarter.

It needs to ignore a few more things, like private packages, tests,
sub-sub-packages, etc.
doc: Broadly categorize example plots.
Merge pull request #1356 from QuLogic/doc-sphinx-extensions

Updates to sphinx extensions