Improve history API docs
Fix doctest
Merge pull request #5454 from takluyver/history-docs

Improve history API docs