BUG: rest_comments: use a temporary dir for Sphinx builds

Use a separate temporary compilation directory for each Sphinx invocation. This avoids possible race conditions.

Also cleaned up the code, and fixed an issue where the conf file failed to get copied to the compilation dir.

(The test failure is unrelated and exists also at master)