DOC/CI: Fix building docs with --no-api
- [ ] closes #xxxx
- [ ] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

Fixes running docs via

     python make.py --no-api

A few notes:

 - The removed check `if os.path.exists(path):`; will incorrectly raise if docs are being rebuilt.
 - The value `dirname` returned by `os.walk` is an absolute path, but the check was treating it as relative.
 - If docs are built with api and then rebuilt with --no-api, we want to exclude everything in the `reference` directory; in particular `reference/api`.
@github-actions pre-commit lgtm.