Build xhtml and haddock only when `HADDOCK_DOCS=YES`

This fixes #8558