Improve document target.

Do not rebuild when not necessary.