This moves the example implementation from __main__.py to the docs
tree so it isn't confused for production code. A unit test is also
added to ensure that the example is kept up to date with any changes
in the API.
Change-Id: I92aa685f410ae0e56d5d55a15812edaae83c8ff1