Works around https://github.com/rtfd/readthedocs.org/issues/2708 and fixes #360. Patch from @nicoddemus.