OpenLayers 2.x is not under active development any more. Go to http://openlayers.org/en/latest/doc/ to view the latest OpenLayers 3.x docs.
One of the guiding principles of OpenLayers development has been to maintain a set of small examples of most functionality, allowing the library to demonstrate most of what it can do by example. This means that our examples are typically our most up to date source of documentation, and provide more than 100 different code snippets for use in your applications.
These examples are available from the OpenLayers Examples page.