Scan documentation and examples revamp

Updated documentation for "scan", and moved all code from comments to
real code in a separate private section.