astropy/astropy — pull request #2852 by embray (2014-08-13 20:17:57+00:00)
Title: Add a silly automatic registry of known formatter classes

One advantage of doing things this way, is that it enables user-defined unit formatters (all one has to do is define a subclass of `astropy.units.format.Base`). This should generally be *discouraged*, but at the same time it's good to have the ability available when absolutely necessary.

This also allows the name used to look up a formatter to be different from the class name. This was motivated primarily by my rambling [here](https://github.com/astropy/astropy/pull/2622/files#diff-0e1866aba1b024fc5a0b56842983d96eR99). All formatter classes now have a `.name` class attribute which contains the name they are looked up by. By default this is just `__class__.__name__.lower()`, but it may be customized. For example in the case of #2622 the class can be defined:

```
class LatexInline(Base):
name = 'latex_inline'
```

where the name `'latex_inline'` is perhaps a bit easier on the eyes than `'latexinline'`.