astropy/astropy — pull request #1669 by taldcroft (2013-10-24 18:45:25+00:00)
Title: Add function to get unified I/O formats and auto-update read/write docstrings

This PR does a few things:

- Add `io.registry.get_formats(data_class=None)` function to get a Table of the available formats for `data_class`.
- Add code in `register_reader` and `register_writer` to automatically insert an RST table of the available formats into the docstring of the appropriate class method.
- Include the table of available formats into the exception message if the user gives an invalid format.

See the preview [Table.write](http://hea-www.harvard.edu/~aldcroft/tmp/astropy/html/_generated/astropy.table.table.Table.html#astropy.table.table.Table.write) docstring (and the corresponding Table.read a little up the page) to see how this looks. The table values there are automatically created.

An example of the new exception message is:
```
Exception: No writer is defined for format 'jun' and class 'Table'.
The available formats are:
Format Read Write Auto-identify
--------------------------- ---- ----- -------------
aastex Yes Yes No
ascii Yes Yes No
ascii.aastex Yes Yes No
ascii.basic Yes Yes No
ascii.commented_header Yes Yes No
ascii.fixed_width Yes Yes No
ascii.fixed_width_no_header Yes Yes No
ascii.fixed_width_two_line Yes Yes No
ascii.ipac Yes Yes No
ascii.latex Yes Yes Yes
ascii.no_header Yes Yes No
ascii.rdb Yes Yes Yes
ascii.tab Yes Yes No
fits Yes Yes Yes
hdf5 Yes Yes Yes
ipac Yes Yes No
latex Yes Yes No
rdb Yes Yes No
votable Yes Yes Yes
```

Although I expect some of this to get re-worked when the unified I/O structured is refactored to use a class structure, for now this should go a long way to improving usability.