refactoring and improved input validation for rebuildDocumentation

* replaced toAbsolutePath by pathExists / ensurePathExists and p.resolve
* throw a sensible error message when apiDocPath hasn't been set
* removed redundant variabele called 'node'
* removed unused import